[Fontconfig] Asking FontConfig for a font that supports a script

Behdad Esfahbod behdad at behdad.org
Thu Jul 28 13:58:24 PDT 2011

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.


> Thanks,
> Sairus

More information about the Fontconfig mailing list