[cairo] solutions for display text with Asian fonts

Uli Schlachter psychon at znc.in
Mon Jun 4 01:25:48 PDT 2012


Hi,

On 04.06.2012 09:57, Jihe Wei wrote:
> When we try to show text with multi-language,
> like Asian fonts(Chinese, Japanese and Korean).
> But can't display them except some squares.
>
> also
> http://blog.vlad1.com/2007/12/11/graphics-in-mozilla/
> says "The toy font API that’s present in Cairo can be ignored,
> as it does not support international text and is there only for convenience
> for smaller projects."
>
> so what's your opinion?

So let's first make it clear what said toy font API is:
cairo_show_text() and cairo_select_font_face()

What should applications use instead? The docs point at cairo_show_glyphs() / 
cairo_show_text_glyphs() and font-backend specific functions like e.g. 
cairo_ft_font_face_create_for_pattern().

However, for these APIs, you are rendering glyphs instead of a text. Converting 
your text into glyphs is something that cairo does not do for you (unless you 
use the toy text API). If you want a solution that should work everywhere, you 
should take a look at Pango[0]. With PangoCairo, you can make Pango draw to a 
cairo_t and thus continue using cairo. Pango will convert your text to glyphs 
and use the non-toy API for doing its job.

Hopefully this helped.
Uli

[0] http://www.pango.org


More information about the cairo mailing list