[cairo] How to check if a font exists in Cairo and Pango?
Ken Resander
kresander at yahoo.com
Wed Apr 10 09:01:34 PDT 2013
My application should check if a font exists and if it does not try the next font preference obtained from the user, a bit like processing a font-choice list in CSS.
Cairo:
const char * str = "nosuchfont";
cairo_font_face_t * ff =
cairo_toy_font_face_create ( str ,
CAIRO_FONT_SLANT_NORMAL ,
CAIRO_FONT_WEIGHT_NORMAL ) ;
const char * toyfamilyis = cairo_toy_font_face_get_family ( ff );
The toyfamilyis was returned as 'nosuchfont'. The manual mentions that toy_font_face_create and the cairo_font_select_face do not report back whether the font exists or not. A pity. If it returned NULL for a non-existent choice then my program could loop through the user preferences.
I also tried pango:
PangoFontDescription * pfd = pango_font_description_from_string ( str );
const char * familyis = pango_font_description_get_family(pfd);
This time familyis was also returned as 'nosuchfont'.
I have read somewhere that pango can tell if a font exists.
How can I make it return this information?
Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130410/0577fbc5/attachment.html>
More information about the cairo
mailing list