[cairo] show_glyphs and writing text

Carl Worth cworth at cworth.org
Mon Dec 17 08:27:46 PST 2007


On Mon, 17 Dec 2007 16:05:35 +0200, Donn wrote:
>  It seems I can write glyphs, just not the ones I expect. I gather it's all
> tangled up in encodings and font backends etc., but is there any easy way to:

The easy way is called cairo_show_text. Using cairo_show_glyphs
requires you to reach down into the underlying font system, (freetype,
for example), to determine glyph indices. And at that point you really
want to just be using pango for all that, (and for the so much more
that it does).

> I realize that show_text() is the easier, but there are all these implications
> that's it's not fit for much (unicode issues?) and I am also just trying to
> be thorough. I will also address pango soon.

Just for your information, there aren't really any "unicode issues"
that make cairo_show_text not fit for much. It accepts a UTF-8-encoded
string, so you can display any glyphs in your font with it. But you
are right that an application will grow out of cairo_show_text very
quickly, (and this is by design). Here are some of the ways that
cairo_show_text is not fit for much:

    * It will only display glyphs from a *single* font. If your string
      requires glyphs from multiple fonts, then you're stuck, (or
      you'd have to break it up and call cairo_select_font_face;
      cairo_show_text for each run requiring a different font).

    * Its layout is bad, even laughable---it doesn't even try to do
      the right thing. A library like pango does, though.

But for little demos, it's definitely hard to beat cairo_show_text.
It's easy to use and it makes some text appear.

I think a good set of demos would then show that pango integrates
nicely with cairo, and it's really not that much harder to use than
cairo_show_text.

(And of course, cairo_show_glyphs *does* exist for anyone who wants to
duplicate pango's functionality within their own application.)

-Carl
-------------- 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/20071217/1915ff32/attachment.pgp 


More information about the cairo mailing list