Reputation: 50778
What makes Windows choose a certain font rather than another when the target font is not available ?
I'm using following code to create a certain font.
somefont.CreateFont(-11, 0, 0, 0, FW_NORMAL, 0, 0, 0,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH|FF_SWISS, "Segoe UI");
Now if Segoe UI is not available (as on Windows XP), the font mapper automatically chooses "Arial" as fall back. This is actually what I want but what makes Windows XP choose "Arial" rather than some other sans serif font such as "Microsoft Sans Serif".
Upvotes: 1
Views: 841
Reputation: 698
There seems to be very little information on the internal workings of the font mapper online. If this very old article is still applicable, then
A penalty is assessed for each mismatch [in font attributes], and the penalties are cumulative. The mapper tracks the physical font with the lowest penalty score...
and
In the case where two different fonts have exactly the same penalty, the first font that was inspected is the one that is selected. An application does not have control of this ordering.
From there I'd guess that you can never be sure which FF_SWISS
font is selected if "Segoe UI" is not present. It would be instructive though to install a swiss font that has a name starting with "aa" to see whether the inspection order is roughly alphabetical.
(@Hans Passant: As I understand it, font fallback only happens when you have already selected a font into a device context and then try to render some characters for which the font does not contain glyphs. See e.g. Font Linking vs. Font Fallback by Michael Kaplan.)
Upvotes: 2