[cairo] Rendering UTF-8 and non-standard text
Carl Worth
cworth at cworth.org
Wed Jan 23 08:56:42 PST 2008
On Wed, 23 Jan 2008 10:57:23 -0500, wrote:
> I am trying to render 'non-standard' text.? For example, using a
> UTF-8 string of hebrew text hardcoded in my source file. The
> text?appears correctly in the code, characters are properly ordered
> right to left.? However, when I render them using a hebrew font for
> some reason the characters are reversed.? I tried setting the locale
> but this has no affect.? Do I need to render each character one at a
> time or should I be able to render the string properly?
Hi Robert!
Thanks for asking your question here.
It sounds like you're using cairo_show_text(). This API is what we
call the "toy API". By design, it is very braindead---the only layout
it does is strictly left-to-right and not at all clever. So it's
really not what you want here.
Here you've got a need for some real text layout---not a toy. What
cairo provides for this is the cairo_show_glyphs() API. But it
requires that you layout each glyph in code above cairo. And for that,
we highly recommend you use pango. It should be able to take care of
all of your layout needs.
Here's a simple example showing how pango and cairo integrate, (but it
doesn't happen to demonstrate any RTL layout):
http://cairographics.org/~cworth/utf8test-pango.c
Please feel free to ask on this list if you have any difficulty with
pango. And have fun with cairo!
-Carl
PS. It occurs to me that we should get an example like the
above properly linked into the main cairographics.org website. Perhaps
a new FAQ answer on using pango with cairo. Behdad?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080123/72551e60/attachment.pgp
More information about the cairo
mailing list