[cairo] 回复: How to show chinese text using cairo
Simon Sapin
simon.sapin at exyr.org
Mon May 6 06:37:18 PDT 2013
Le 06/05/2013 15:13, 快乐2013 a écrit :
> Hi, what I have my code as below:
>
> cairo_select_font_face (cr, "Arial Unicode MS",
> CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
> cairo_set_font_size (cr, 32.0);
> cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
> cairo_move_to (cr, 10.0, 50.0);
>
> cairo_show_text (cr, "Hello, 中国人 "); // this clause cannot work
>
> I wonder if the following can work at all.
>
> // does this clause can work?
> cairo_show_text (cr, toUtf8("Hello, 中国人 "));
>
> here toUtf8 is a functioin doing convertion from ansi to utf8
Hi,
I don’t know what is the character encoding of string literals on your
system (perhaps just the encoding your editor is saving as), but yes,
cairo_show_text does support Unicode and expects a NUL-terminated UTF-8
string.
http://cairographics.org/manual/cairo-text.html#cairo-show-text
But this is a the "toy" text API, you might get better results with Pango.
Cheers,
--
Simon Sapin
More information about the cairo
mailing list