John Alexander Thacker
2005-Nov-21 08:50 UTC
[Fontconfig] Getting reasonable fonts for languages other than the current locale
On Sun, Oct 26, 2003 at 07:53:25AM -0800, Keith Packard wrote:> > The idea is to first sort including FC_LANG, then pull off the head of > that list until all of the languages in the pattern FC_LANG are supported. > Then, re-sort the remaining elements ignoring FC_LANG. Return the whole > list. > > The result will be: > > 1) Strongly bound family names > 2) A minimal set of fonts as required to support FC_LANG > 3) The rest of the fonts sorted according to the <alias> entries > > Comments? Sample code?Seems reasonable, and sounds like it would solve my issues. Thanks for working on it. I''m still a little confused why both your suggestion before involving strong binding and Owen''s suggestion didn''t seem to work as I expected-- both caused apps to prefer Japanese fonts for everything, including Roman characters. This sounds like it would have the behavior I want, which is also what I got using your other suggestion together with unsetting the locale. Would it be possible to override the default language obtained from the environment variables? As a temporary measure, I''d like to tell fontconfig to ignore the locale and leave the desired language as unset so that your other suggestion will work. John Thacker
Keith Packard
2005-Nov-21 08:50 UTC
[Fontconfig] Getting reasonable fonts for languages other than the current locale
Owen and I were chatting on IRC yesterday about the problem we''ve all see with fontconfig -- a user in an ''en'' locale will get really bad choices for languages that use non-Latin scripts. One obvious example is when displaying a mixed English/Arabic document -- the ''en'' locale forces the selection of fonts that support ''en'' even for Arabic parts of the document. I came up with a suggestion to fix FcFontSort which seems to help in this situation, although it is rather specific to the language matching features. I think that''s probably OK as FcFontSort already is rather focused on coverage. The idea is to first sort including FC_LANG, then pull off the head of that list until all of the languages in the pattern FC_LANG are supported. Then, re-sort the remaining elements ignoring FC_LANG. Return the whole list. The result will be: 1) Strongly bound family names 2) A minimal set of fonts as required to support FC_LANG 3) The rest of the fonts sorted according to the <alias> entries Owen pointed out one problem with this plan -- Pango is currently dropping fonts from the list which don''t include good layout information if fonts further down do include that. Re-sorting will mean that Pango may find fonts inappropriate for a particular language before it finds the right ones: {ar without OT tables} {fa with OT tables} {ar with OT tables} In this case, Pango will end up using the farsi font to display arabic. Really, the right solution is to order the aliases so that the ar font with OT tables appears first, or alternatively include OT table information in fontconfig and have Pango include requests for that in the sorting information. The latter is apparantly "hard" to do in Pango. However, this change doesn''t really break things that aren''t broken -- the font elision step in FcFontSort will likely drop the {ar with OT tables} font in any case, even if it is sorted before {fa with OT tables}. So, this change makes Pango no worse off :-) Comments? Sample code? -keith