[cairo] rendering UTF8 text

Carl Worth cworth at cworth.org
Tue Jun 26 07:32:34 PDT 2007


On Tue, 26 Jun 2007 11:00:08 +0200, Ulrich Mierendorff wrote:
> I do not understand exactly why this is a "toy" API. Are there any
> technical reasons?

The technical reason that a "real" text API is a huge effort, (of the
scale of cairo itself or larger), so we didn't want to do that inside
of cairo. What we did is the following:

 * Provide cairo_show_text which allows you to very easily get _some_
   text to appear quite easily. It's suitable for quick demos and
   proofs of concept, but you'll quite easily run into its
   limitations. Serious applications are unlikely to be satisfied by
   its limitations, (and we don't plan to extend its capabilities).

   You ran into one of the limitations which is that cairo_show_text
   does not do any "font merging". It will only display glyphs from a
   single font at a time. If you want to display characters from
   multiple fonts with cairo_show_text, you'll have to switch fonts
   with cairo_select_font_face between the characters.

 * Provide cairo_show_glyphs as the basis for "real" API developed
   outside of cairo. This API allows much more control, (individual
   placement of every glyph), but also involves quite a bit more
   effort to use, (must talk to directly to underlying font system
   such as freetype, ATSUI, or whatever the win32 font layer is
   called; must convert from characters to font glyph indices; etc.).

You don't _have_ to use pango to use the real API, but it's definitely
a lot less effort to use it rather than inventing everything it does
from scratch. Plus, it is nicely integrated with cairo making it very
easy to use the two together. Here's a simple example showing the
basics:

	http://people.freedesktop.org/~cworth/utf8test-pango.c

(Although, the last time I shared that with somebody, Behdad pointed
out a couple of style issues with it, and I haven't fixed them. I plan
to resurrect the cairo wiki this week and we can start hosting
examples there for people to collaborate on improving them.)

Good luck, and have fun with cairo,

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://cairographics.org/archives/cairo/attachments/20070626/48124336/attachment.pgp 


More information about the cairo mailing list