[Fontconfig] How to use FcFontMatch to find a font with a given character

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Fri Jun 29 11:12:27 UTC 2018


On Fri, 29 Jun 2018 18:12:40 +0800, Elias Mårtenson wrote:

> When I use FcMatchPattern, the program returns DejaVuSans.ttf. If I
> use FcMatchFont instead, it returns FreeMono.ttf.
>
> The interesting thing is that none of these fonts actually contains
> U+0x63A (checked by reading the "charset" value).

I’m not sure what the difference is, but I gather that Fontconfig never
fails to return a font, as long as it can find at least one on your
system. Remember that Fontconfig is all about “best effort” to match
what you require, rather than “perfect match”. I think FcMatchPattern is
the right one to use. You can then scan the list of candidates returned,
querying their actual “charset” properties to see which one(s) are
sufficient for your needs.

I include an example of this in the readme for my Python wrapper for
Fontconfig <https://github.com/ldo/python_fontconfig/>.

By the way, just checked DejaVu Sans on my system, and it does indeed
have “U+063A ARABIC LETTER GHAIN”.


More information about the Fontconfig mailing list