[Fontconfig] What metric does fontconfig use to select a font

Raimund Steger rs at mytum.de
Mon Sep 5 11:24:42 PDT 2011


Hi,

> On Mon, Sep 5, 2011 at 7:29 PM, Cyker Way <cykerway at gmail.com> wrote:
> [...]
>> BTW, how does fontconfig sort the precedence of fonts according to the
>> application request? If this question is not fully answered, maybe other
>> problems will arise in the future. Do you have any idea on that?

You could say that the "order" of the fonts is that of their distance from
the application-provided pattern.

It is detailed on

  http://www.freedesktop.org/software/fontconfig/fontconfig-user.html#AEN25

In short:
Your application specifies a pattern with a number of properties, like
family, pixelsize, etc. (Example: "Bitstream Vera Sans:pixelsize=13")
This pattern is modified through the <match target="pattern"> rules in
your config files.
(Every element in the pattern can in fact be a list ordered from good
candidate to not-so-good candidate.)
The modified pattern is then compared to all fonts that have been scanned,
using a predefined order of properties -- see the above link.
Properties like foundry and family weigh more than say, outline. Others
like file or fontformat are not used at all, so you cannot select a font
based on its filename.
It should also be noted that some applications have their own fallback
scheme on top of what fontconfig provides, e. g. based on CSS.

> [...]
> you may get more information from the debugging log by setting the env var
> like FC_DEBUG=4.

This is also a very good idea (be prepared for some output).

Raimund



-- 
R.Steger Tel. +49-179-2981632 icq 16845346



More information about the Fontconfig mailing list