[tlbuild] Problems with xdvipdmfx (at least) and some fonts

Fabian Greffrath fabian at greffrath.com
Mon Aug 31 08:08:23 CEST 2015


Hi all,

Am Dienstag, den 25.08.2015, 19:17 +0200 schrieb Fabian Greffrath:
> Remains the (probably Debian-specific) problem that occurs when two
> fonts with the same /FontName but different glyph coverage are
> installed into fontconfig's search path and then apparently get mixed
> up by XeTeX. Do you think there is anything that can be done about
> that?

I think I found the reason for this: The culprit is that
XeTeXFontMgr_FC::initialize() calls FcFontList() to create an FcFontSet
that contains all fonts available on the system. However, this font set
is completely unsorted, fontconfig adds fonts to this set as they come.
For example, this is the output I receive with the second chunk (which
you should not apply) of the attached patch:

$ xelatex test2.tex | grep Palladio
 * 152: URW Palladio L  /usr/share/fonts/type1/texlive-fonts-recommended/uplri8a.pfb
 * 200: URW Palladio L	/usr/share/fonts/type1/gsfonts/p052024l.pfb
 * 229: URW Palladio L	/usr/share/fonts/type1/gsfonts/p052003l.pfb
 * 260: URW Palladio L  /usr/share/fonts/type1/texlive-fonts-recommended/uplr8a.pfb
 * 283: URW Palladio L  /usr/share/fonts/type1/texlive-fonts-recommended/uplb8a.pfb
 * 339: URW Palladio L	/usr/share/fonts/type1/gsfonts/p052023l.pfb
 * 430: URW Palladio L	/usr/share/fonts/type1/gsfonts/p052004l.pfb
 * 437: URW Palladio L  /usr/share/fonts/type1/texlive-fonts-recommended/uplbi8a.pfb

Please note how fontconfig mixes up the Palladio fonts from the texlive
and the gsfonts packages. Later on in the code, xetex iterates through
this font set to find a suitable font for rendering and will inevitably
also mix up both font sets.

However, there is an API in fontconfig that allows for ordering the
fonts in the returned font set by decreasing relevance to the search
pattern: FcFontSort(). It does not makes much sense to call this
function in XeTeXFontMgr_FC::initialize(), because the actual search
pattern, i.e. "URW Palladio L", is not yet known at this stage. Thus, I
postponed the creation of the font set to the
XeTeXFontMgr_FC::searchForHostPlatformFont() function. Please note how
the fonts in the returned font set are now (a) grouped by relevance to
the search pattern and (b) how preference is given to the font set with
the wider glyph coverage:

$ xelatex test2.tex | grep Palladio
 * 0: URW Palladio L	/usr/share/fonts/type1/gsfonts/p052003l.pfb
 * 1: URW Palladio L	/usr/share/fonts/type1/gsfonts/p052004l.pfb
 * 2: URW Palladio L	/usr/share/fonts/type1/gsfonts/p052023l.pfb
 * 3: URW Palladio L	/usr/share/fonts/type1/gsfonts/p052024l.pfb
 * 4: URW Palladio L    /usr/share/fonts/type1/texlive-fonts-recommended/uplb8a.pfb
 * 5: URW Palladio L    /usr/share/fonts/type1/texlive-fonts-recommended/uplbi8a.pfb
 * 6: URW Palladio L    /usr/share/fonts/type1/texlive-fonts-recommended/uplr8a.pfb
 * 7: URW Palladio L    /usr/share/fonts/type1/texlive-fonts-recommended/uplri8a.pfb

Please note that the number of returned fonts does not change between
FcFontList() and FcFontSort(), it is just the ordering with relevance
to the search pattern.

I have also added two further function call to the patch:
FcConfigSubstitute() and FcDefaultSubstitute(). They are responsible
for font alias substitution, e.g. with calling them it is possible to
request the font "Times" and fontconfig considers "Nimbus Roman No9 L"
as the most suitable substitute. I am not sure if they are strictly
needed, but the fontconfig developers guide states that "the results
will not be correct" if FcFontSort() is called without them [1].
Furthermore, the third parameter to FcFontSort() should always be
FcFalse, else fontconfig will trim fonts off the returned list if they
provide less Unicode coverage than fonts with higher ordering.

Please share your thoughts about this approach!

Thank you,

Fabian

[1] http://www.freedesktop.org/software/fontconfig/fontconfig-devel/fcfontsort.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.tex
Type: text/x-tex
Size: 291 bytes
Desc: not available
URL: <http://tug.org/pipermail/tlbuild/attachments/20150831/ec8f9ca4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xetex-fontconfig.patch
Type: text/x-patch
Size: 1760 bytes
Desc: not available
URL: <http://tug.org/pipermail/tlbuild/attachments/20150831/ec8f9ca4/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://tug.org/pipermail/tlbuild/attachments/20150831/ec8f9ca4/attachment-0002.bin>


More information about the tlbuild mailing list