GNOME Bugzilla – Bug 113452
fallbacks in pango_fc_font_get_metrics()
Last modified: 2009-01-03 00:03:23 UTC
pango_xft_get_context does... context = pango_xft_get_context (display, 0); which does not look multihead safe to me. FYI, in my case it is called from pango_xft_font_get_metrics from pango_font_get_metrics which in turn is called from my code where I actually have a valid context.
A single font can be used for multiple PangoContext's (which is good, since there are usually many PangoContext's for an app), so we can't retrieve the PangoContext that you already have. PangoContext is a lightweight structure, and creating the context is much less work than the rest of the metrics computation you are looking at. (Which is fortunately cached, so only done once for PangoXftFont) So, the right fix is entirely trivial: - _pango_xft_font_map_get_info (xfont->fontmap, &display, NULL); - context = pango_xft_get_context (display, 0); + _pango_xft_font_map_get_info (xfont->fontmap, &display, &screen); + context = pango_xft_get_context (display, screen);
I'm not worried about the weight of the operation, but rather about whether the locally created context has the right set of attributes. By construction it must be using default settings for language and direction, for example.
A PangoXftFont corresponds directly to a single FreeType font, so language, direction and so forth don't matter. There is a problem that we dont' have any way of disabling fallbacks, so if the font doesn't have all the characters in the string being measured, the fallbacks *will* be language dependent, but that needs to be fixed by turning off fallbacks (Bug 105553, though with the added complication that we don't want to allow space for the "Unknown Glyph" character ... in fact, we want to average the characters in the sample string that we *are* in this font ... so we'll probably have to iterate through the resulting glyph string to figure things out.)
Did the easy part of the fix. Tue May 27 15:01:24 2003 Owen Taylor <otaylor@redhat.com> * pango/pangoxft-font.c (pango_xft_font_get_metrics): Get the fontnmap for the right screen (#113452, Morten Welinder)
Should actually be pretty trivial once Bug 105553 is fixed, but non-critical so punting anyways.
Retitling to better reflect current code organization and the remaining problem.
I actually don't think the current behaviour is undesirable. If you ask for Persian metrics of your Latin fonts, whatever fallback font will be used to render Persian text should also be used to compute Persian metrics. Closing.