src/fcmatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit bf3bfa72d91e8bc37903d7e1bb7ac23c6ef4952a Author: Behdad Esfahbod <behdad at behdad.org> Date: Wed Jun 22 13:06:19 2011 -0400 Fix stupid bug in FcFontSort() I broke FcFontSort() language handling at the end of 2008 with this commit: c7641f28 G-d knows how many of the lang-matching bugs in bugzilla will be fixed by this changed... I''m really sorry, everyone! diff --git a/src/fcmatch.c b/src/fcmatch.c index f111be5..1b9162b 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -749,7 +749,7 @@ FcFontSetSort (FcConfig *config, * If this node matches any language, go check * which ones and satisfy those entries */ - if (nodeps[f]->score[MATCH_LANG_INDEX] < 200) + if (nodeps[f]->score[MATCH_LANG_INDEX] < 2000) { for (i = 0; i < nPatternLang; i++) {
Sairus Patel
2011-Jul-26 18:01 UTC
[Fontconfig] Asking FontConfig for a font that supports a script
I want to query FontConfig: - "give me a font for Latin characters" - "give me a font for Simplified Chinese characters" - "give me a font for Mathematical symbols" etc Do I use FC_LANG when creating the pattern? It doesn''t seem quite the right fit, since there are several languages, including "en", that use Latin characters. Yet the codebase I''m dealing with uses FC_LANG for this. I thought FC_CHARSET might be a possibilty, but I don''t see it used in FcDefaultSubstitute. If FC_LANG is what I should use, then is the valid list of parameter values ISO 639-1? This seems to be suggested by http://www.freedesktop.org/software/fontconfig/fontconfig-devel/x31.html#AEN44. Or is it up to the person who sets up the config files? I looked at thread "ISO 15924 font selection" in the archives but didn''t see any resolution. Thanks, Sairus
Behdad Esfahbod
2011-Jul-28 20:58 UTC
[Fontconfig] Asking FontConfig for a font that supports a script
Hi Sairus, On 07/26/11 14:01, Sairus Patel wrote:> I want to query FontConfig: > - "give me a font for Latin characters" > - "give me a font for Simplified Chinese characters" > - "give me a font for Mathematical symbols" > etc > > Do I use FC_LANG when creating the pattern? It doesn''t seem quite the right fit, since there are several languages, including "en", that use Latin characters. Yet the codebase I''m dealing with uses FC_LANG for this. > > I thought FC_CHARSET might be a possibilty, but I don''t see it used in FcDefaultSubstitute.FcDefaultSubstitute is not the right place to look. fcmatch.c is. If you check that file, you see that indeed FC_CHARSET is matched. But it''s up to you to populate the charset for different scripts. I have a hard time seeing how matching on whole scripts can be useful. For example, I don''t think I have seen any font that supports the full Arabic script. Or even if there is, that''s hardly ever a useful criteria since no language uses the entire Arabic script as encoded in Unicode. So, what is your usecase?> If FC_LANG is what I should use, then is the valid list of parameter values ISO 639-1? This seems to be suggested by http://www.freedesktop.org/software/fontconfig/fontconfig-devel/x31.html#AEN44.It''s loosely defined. In the future it will be BCP49. Right now it''s "whatever glibc uses". For useful values, check the fontconfig/fc-lang directory.> Or is it up to the person who sets up the config files? > > I looked at thread "ISO 15924 font selection" in the archives but didn''t see any resolution.Yeah, we haven''t been able to define a useful select-by-script behavior yet. Suggestions are welcome. Cheers, behdad> Thanks, > Sairus
Sairus Patel
2011-Jul-28 21:37 UTC
[Fontconfig] Asking FontConfig for a font that supports a script
Hi Behdad, The software I''m working on has its own simple fallback mechanism, used if the user-specified font doesn''t support a given character. If the character is a Latin character, the software wants to ask FontConfig for a Latin script font, and then will try to see if that font supports the character. Yes, it''s very simplistic, but we do have a more sophisticated hand-tuned mechanism in place for those situations where that''s possible. We however need to cover the situation where no hand-tuned mechanism is available, and so we have to rely on FontConfig for this.>If you >check that file, you see that indeed FC_CHARSET is matched. But it''s up to >you to populate the charset for different scripts.By this you mean the software would call FcFreeTypeCharSet and associate it with each font on the system? I think this would not be efficient enough for our needs. A mechanism whereby the operator of the FontConfig setup on that device would associate particular fonts with particular scripts in the config files, just as happens for associating fonts with generic family names like serif or sans-serif, would be more desirable.> It''s loosely defined. In the future it will be BCP49. Right now it''s > "whatever glibc uses". For useful values, check the fontconfig/fc-lang directory.Thanks. It sounds like language matching is the next best facility we have available to script matching right now. Best, Sairus -----Original Message----- From: Behdad Esfahbod [mailto:behdad.esfahbod at gmail.com] On Behalf Of Behdad Esfahbod Sent: Thursday, July 28, 2011 1:58 PM To: Sairus Patel Cc: fontconfig at fontconfig.org Subject: Re: [Fontconfig] Asking FontConfig for a font that supports a script Hi Sairus, On 07/26/11 14:01, Sairus Patel wrote:> I want to query FontConfig: > - "give me a font for Latin characters" > - "give me a font for Simplified Chinese characters" > - "give me a font for Mathematical symbols" > etc > > Do I use FC_LANG when creating the pattern? It doesn''t seem quite the right fit, since there are several languages, including "en", that use Latin characters. Yet the codebase I''m dealing with uses FC_LANG for this. > > I thought FC_CHARSET might be a possibilty, but I don''t see it used in FcDefaultSubstitute.FcDefaultSubstitute is not the right place to look. fcmatch.c is. If you check that file, you see that indeed FC_CHARSET is matched. But it''s up to you to populate the charset for different scripts. I have a hard time seeing how matching on whole scripts can be useful. For example, I don''t think I have seen any font that supports the full Arabic script. Or even if there is, that''s hardly ever a useful criteria since no language uses the entire Arabic script as encoded in Unicode. So, what is your usecase?> If FC_LANG is what I should use, then is the valid list of parameter values ISO 639-1? This seems to be suggested by http://www.freedesktop.org/software/fontconfig/fontconfig-devel/x31.html#AEN44.It''s loosely defined. In the future it will be BCP49. Right now it''s "whatever glibc uses". For useful values, check the fontconfig/fc-lang directory.> Or is it up to the person who sets up the config files? > > I looked at thread "ISO 15924 font selection" in the archives but didn''t see any resolution.Yeah, we haven''t been able to define a useful select-by-script behavior yet. Suggestions are welcome. Cheers, behdad> Thanks, > Sairus
Behdad Esfahbod
2011-Jul-28 21:52 UTC
[Fontconfig] Asking FontConfig for a font that supports a script
On 07/28/11 17:37, Sairus Patel wrote:>> >If you >> >check that file, you see that indeed FC_CHARSET is matched. But it''s up to >> >you to populate the charset for different scripts. > By this you mean the software would call FcFreeTypeCharSet and associate it with each font on the system? I think this would not be efficient enough for our needs. A mechanism whereby the operator of the FontConfig setup on that device would associate particular fonts with particular scripts in the config files, just as happens for associating fonts with generic family names like serif or sans-serif, would be more desirable.Fontconfig has done that when creating caches, so the font charset is sitting in a cache file. It''s not hugely expensive, specially given that you should cache the result per-script, so this happens once per script at most. behdad