[cairo] text to postscript rendering
cworth at cworth.org
Wed Feb 27 08:02:27 PST 2008
On Wed, 27 Feb 2008 14:03:50 +0100, Jürgen Ladstätter wrote:
> cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
> cairo_text_path(cr, "test text" );
> and it works very well, but when i now use special characters like
> $, € there is no useful output. Anything known about that?
Yes. The issue here is that cairo's "toy" functions like
cairo_select_font_face and cairo_text_path only work with a single
font at a time. So when you ask for a glyph that doesn't exist in the
font you selected, you won't get any output for that glyph, (that is,
cairo_text_path doesn't do any "font substitution" for you).
> Are there any other functions to select fonts? Because i cant
> exchange "Sans" with any other font i have in MS Word.
You should be able to select any font available on your system by
family name. Cairo-win32 hackers, any reason this wouldn't be working?
Meanwhile, there is another way to deal with fonts, and that is the
"real" font APIs. They are quite a bit harder to use though. First
you'll have to talk to native win32 APIs to open a font, (either an
HFONT or a LOGFONTW), then call one of these functions:
to create a cairo_font_face_t from which you can then call
cairo_scaled_font_create and cairo_set_scaled_font.
Finally, you will also have to do all your own font substitution and
layout and also manually lookup font-glyph IDs for each glyph you
want, and then call cairo_show_glyphs to actually display the glyphs.
So that's definitely a lot more work, and cairo *still* doesn't do any
of the font substitution for you. :-P
But that "real" API does provide the chance for someone to do all this
hard work and provide a library on top of cairo that provides font
substitution, high-quality layout, line-breaking etc. The pango
library is exactly such a library. And here's a simple program showing
how to use it with cairo:
And pango should work just fine on win32 platforms as far as I
understand, (it's not something I've ever tried though).
Hmm... it's probably time for me to roll all of the above up into a
FAQ entry. This issue does come up every once in a while.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080227/7bd17c55/attachment.pgp
More information about the cairo