[Fontconfig] shouldn't FcDefaultSubstitute() be called before FcConfigSubstitute()?

Mike FABIAN mfabian at suse.de
Sun Apr 4 08:54:06 EST 2004

I wonder whether FcDefaultSubstitute() should better be called before


I tried to use a rule like the following to replace the scalable
"Nimbus Sans L" with the "Adobe Helvetica" bitmap font for pixel sizes
between 8 and 20:

    <match target="pattern">
            <test name="family">
                    <string>Nimbus Sans L</string>
            <test name="pixelsize" compare="more_eq">
            <test name="pixelsize" compare="less_eq">
            <edit name="family" mode="prepend" binding="same">
                    <string>Adobe Helvetica</string>
            <edit name="foundry" mode="prepend" binding="same">

As "Nimbus Sans L" is a Helvetica clone, the "Adobe Helvetica" bitmap
font should be a reasonably good replacement at small sizes for people
who absolutely insist on using bitmaps.

Although I don't want to use that myself and don't want to make it the
default on SuSE Linux either, I explored whether such a rule is
possible to be able to give users who greatly prefer bitmaps in small
sizes an easy way to get mostly bitmaps on their desktop for small
sizes and anti-aliasing for big sizes. Similar like it can be done
with embedded bitmaps for CJK fonts. Quite a few users requested
something like this.

While testing the above rule, I found that testing for "pixelsize"
when matching "pattern" doesn't work when only "size" was requested in
the pattern by the application.

For example when calling 

    xfd -fa "Nimbus Sans L:size=10"

the above rules will not match, even if pixelsize=size/72*dpi is
within range tested.  The reason is that FcDefaultSubstitute is called
*after* FcConfigSubstitute in libXft. Therefore, pixelsize is not yet
set while the above rules are applied.

This makes it impossible to use any rules matching on pixelsize
in the pattern, one never knows whether an application will
request pixels like

    xfd -fa "Nimbus Sans L:pixelsize=16"

or point. Using "size" instead of "pixelsize" in the above rules
doesn't appear to make much sense either, then it will fail if the
application requests a pattern with only "pixelsize" and no
"size". And, rules which are meant to fix rendering issues at small
pixelsizes should match on "pixelsize" and not on "size" because it
depends on the display of course how many pixels a certain point size
has. That's why the rules for the "Bitstream Vera" fonts in
/etc/fonts/fonts.conf match on "pixelsize", e.g.:

	<match target="font">
		<test name="family">
			<string>Bitstream Vera Serif</string>
		<test name="pixelsize" compare="less">
		<edit name="hinting">

But these match on the target "font", and as explained above, this
doesn't work reliably when matching on the target "pattern".

Shouldn't it be possible to match reliably on "pixelsize" also
with target pattern?

Just for testing, I applied the two attached patches to call
FcDefaultSubstitute(). This makes the above rule work for both

    xfd -fa "Nimbus Sans L:size=12:dpi=112"
    xfd -fa "Nimbus Sans L:pixelsize=18.6667:dpi=112"

*But*, if I omit "dpi=112" (which is the correct dpi for my display),
FcDefaultSubstitute() makes dpi default to "75" which results in wrong
conversion from point to pixel for my display.

I.e. just calling FcDefaultSubstitute() is probably also not the right

I think somehow "pixelsize" should be calculated from "size" using the
correct dpi value and added to the pattern before the matching rules
from the config files are applied to the pattern.

But how to do this without any nasty side effects?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: fc-match.patch
Type: text/x-patch
Size: 569 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20040404/23875026/fc-match.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p_fc-default-substitute-first.diff
Type: text/x-patch
Size: 468 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20040404/23875026/p_fc-default-substitute-first.bin
-------------- next part --------------

Mike FABIAN   <mfabian at suse.de>   http://www.suse.de/~mfabian

More information about the Fontconfig mailing list