[Fontconfig] Font matching questions in Fontconfig, Portable

Raimund Steger rs at mytum.de
Mon Oct 1 16:07:02 PDT 2012


mathog wrote:
> PowerPoint on Windows XP lists fonts:  Times, Times New Roman, Arial,
> and Helvetica.  While Arial and Helvetica are identical

This might be like that on your machine, but there's no guarantee. 
Helvetica and Arial are different fonts after all. In your case 
Helvetica might be a printer font that is substituted with Arial for 
on-screen display because the Windows renderer has no better representation.

>[...]
> When fontconfig looks up fonts by name on Windows XP (under cygwin) it
> comes back with, respectively (TrueType font unless otherwise indicated):
>
> Arial            C:/WINDOWS/fonts/arial.ttf     (style Normal)
> Helvetica        C:/WINDOWS/fonts/VeraSe.ttf    (style Roman)
> Times            C:/WINDOWS/fonts/Vera.ttf      (style Roman)
> Times New Roman  C:/WINDOWS/fonts/times.ttf     (style Normal)

I understand this is not what

   fc-list '' family file style

gives you, but what you get with fc-match/FcFontMatch(3) when providing 
such family names? (...see below)

What you get with 'fc-list' is what the fontconfig cache (updated with 
fc-cache) contains. It's all the supported files that fc-cache finds in 
the directories specified by <dir> tags in your fontconfig 
configuration. (It will not include fonts from printer drivers.)

The cache comes into play when

* Applications enumerate fonts for drop-down boxes and such (this is 
what you see in the Inkscape font selector). They often list the first 
available family for every cache entry.

* Applications request a certain font by pattern, i. e. family name. 
That pattern is substituted according to the target="pattern" rules in 
your fontconfig configuration and the result is then fed into a distance 
function to compare with all your cache entries. If 'Times' is no family 
name of any font in your cache, it's up to fontconfig rules to find a 
good alternative.

All of this is user-definable and will not yield the same result across 
different OSes, distributions, home directories etc. This is intended 
behavior and users are typically aware of that. If a user has a setup 
where 'Times' is always mapped to the same as 'Sans', that would be a 
very poor configuration of that system or user account, but I think it's 
not something that you as Inkscape developer need to take care of.
(I think it's a bit strange though, since the default fontconfig 
configuration files should give better aliases, in particular 
30-metric-aliases.conf, if it's included.)

Now the question is what kind of fontconfig configuration Inkscape for 
Windows uses, if any, as there's no system fontconfig on Windows. I 
doubt it's a Cygwin build though. Maybe it ships its own version of the 
GTK/Pango/fontconfig stack. In this case the application you develop 
should probably use the same configuration, i. e. if you're testing with 
Cygwin, you would need to make sure the configuration of your Cygwin 
tree is identical to the one the distributed application uses. You can 
e. g. include 30-metric-aliases.conf in etc/fonts/conf.d there, if it's 
fine with the upstream guys.

For UNIX/Linux builds however, I think second-guessing the user's 
fontconfig setup is not a good idea.

Raimund


-- 
Worringer Str 31 Duesseldorf 40211 DE  home: <rs at mytum.de>
+49-179-2981632 icq 16845346           work: <rs at interface-ag.de>


More information about the Fontconfig mailing list