On Mon, 2006-03-13 at 16:38 +0900, Kenichi Handa wrote: > Hi, > > I'd like to suggest the attached patch to > pango/pango-context.c. > > Pango's shaper engine (struct _PangoEngineShapeClass) can > have a callback function "covers", but it seems that it is > not utilized that much. In the function > get_shaper_and_font_foreach(), the return value of > (PangoCoverageLevel) _pango_engine_shape_covers() is simply > checked against PANGO_COVERAGE_NONE, and if any other value > is returned, that font is accepted. > > I think it is better to try another font if > PANGO_COVERAGE_FALLBACK or PANGO_COVERAGE_APPROXIMATE is > returned here until PANGO_COVERAGE_EXACT is returned. > > That way, pango can use a font most preferred by a shaper > engine while falling back to APPROXIMATE or FALLBACK font. > > What do you think? When the shaper helps select the font there is a basic problem ... I didn't think about it when I first created the system, but discovered it later. The problem is fontconfig ... since we ask fontconfig to "trim" the results when calling FcFontSort(), only one Japanese (say) font will be returned. If there is another Japanese font further down the list, it won't be returned unless it has new characters that the previous fonts don't have. So, I don't think your patch will work out reliably - the font with "APPROXIMATE" or "FALLBACK" coverage may keep your "EXACT" font from being found at all. On the other hand, if you don't trim the results you'll get every single font in the system in the returned list, which would be horrible for performance and memory usage. The right thing to do is probably duplicate the trimming code from fontconfig and combine it with our own logic ... if you look at how trimming is implemented in fontconfig, it's not doing anything that we could do ourselves as efficiently. The other possibility - which could work Graphite and for OpenType, but maybe not as well for you - is to get fontconfig to sort the returned fonts based on what tables they contain, and thus prefer the fonts with silf or GSUB/GPOS tables. Regards, Owen
Attachment:
signature.asc
Description: This is a digitally signed message part