GNOME Bugzilla – Bug 99235
API for getting available sizes for a face
Last modified: 2004-12-22 21:47:04 UTC
If we are interested in supporting bitmap only fonts within the fontconfig framework (and there has been a pretty big demand so far) it would be really nice to the available sizes properly in the GTK+ font selector.
See bug 98952 for one report.
Created attachment 21635 [details] test program
Created attachment 21636 [details] [review] patch
Patch looks almost perfect. Comments I have are: * pango_fc_font_map_pixel_to_point_ratio() is an awkward name. * The implementation of pixel_to_point_ratio() need some work. - The FT2 backend should be using the postscript 72.0 instead of the "correct" 72.27 - The Xft backend isn't going to get things right in the common case where the DPI has been overriden via X resource or XSETTINGS. The only real way of getting the proper DPI is to get the value of FC_DPI from a call to fontmap->default_substitute(); 72./FC_DPI is the right ratio. The question is what pattern to pass to fontmap->default_substitute and how often to call it. I'd probably call it on FcPatternDuplicate (fontset->fonts[i]) once per call to list_sizes(). The alternative, while still calling it once per list_sizes() would be to call it on a fixed pattern like Sans-serif 10, which might be marginally faster.
Created attachment 24680 [details] [review] patch as applied
2003-02-22 Noah Levitt <nlevitt@columbia.edu> * pango/pango-font.h: * pango/pangofc-fontmap.c: * pango/pangowin32-fontmap.c: * pango/fonts.c (pango_font_face_list_sizes): New API for getting available sizes for a bitmap font face.
Couple things noticed glancing at the patch - by convention pango_font_face_list_sizes() should allow NULL for sizes and/or n_sizes. Not terribly useful here but good to be consistent. This is best taken care of in the wrapper rather than in each implementation. I'd probably try to catch + FcPatternGetDouble (tmp, FC_DPI, 0, &dpi); failing or returning 0 and then warn and use a default value (72. maybe); I just don't trust fontconfig that much :-) Finally, we need to file another bug against the win32 backend before resolving this one to actually implemented list_sizes for that backend.
Took care of handling nulls and FcPatternGetDouble failing. Bug 135235 is for the win32 implementation.