run-docs-build: add a custom fonts.conf to fix rsvg-convert errors

rsvg-convert, which we use to convert SVG images to PDFs/PNGs, would
always print out the following error:

  Fontconfig error: Cannot load default config file: No such file: (null)

As a result some SVGs are oddly rendered because it doesn't find the
correct fonts.

This can be easily fixed by setting and exporting the FONTCONFIG_PATH
variable which must point to a directory containing a fonts.conf file.
Since we build on multiple distros, we may not always find this file in
/etc/fonts (installed there by default on many distros). Additionally,
we can also install custom fonts using tlmgr and use them thanks to that
file.

Add a custom fonts.conf that adds /texlive/texmf-dist/fonts to the list
of directories to look for fonts. This files is just based on the
original fonts.conf. Also add the nimbus15 package to the list of tlmgr
installed packages so that we make sure we always use the same font for
rendering images (assuming the SVG files use the "Nimbus Sans L" font).

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Antonin Godard 2025-02-20 15:04:57 +01:00 committed by Richard Purdie
parent abae49b0f6
commit c68e7b7b95
2 changed files with 107 additions and 1 deletions

View File

@ -0,0 +1,100 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<!-- This is a copy of the /etc/fonts/fonts.conf file to configure system font access -->
<!-- Modified to include the texlive fonts -->
<fontconfig>
<description>Fonts configuration file</description>
<!-- Font directory list -->
<dir>/usr/share/fonts</dir>
<dir>/usr/local/share/fonts</dir>
<dir prefix="xdg">fonts</dir>
<!-- Custom directory with texlive fonts -->
<dir>/texlive/texmf-dist/fonts</dir>
<!--
Accept deprecated 'mono' alias, replacing it with 'monospace'
-->
<match target="pattern">
<test qual="any" name="family">
<string>mono</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>monospace</string>
</edit>
</match>
<!--
Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans serif</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>sans-serif</string>
</edit>
</match>
<!--
Accept deprecated 'sans' alias, replacing it with 'sans-serif'
-->
<match target="pattern">
<test qual="any" name="family">
<string>sans</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>sans-serif</string>
</edit>
</match>
<!--
Accept alternate 'system ui' spelling, replacing it with 'system-ui'
-->
<match target="pattern">
<test qual="any" name="family">
<string>system ui</string>
</test>
<edit name="family" mode="assign" binding="same">
<string>system-ui</string>
</edit>
</match>
<!--
Ignore dpkg temporary files created in fonts directories
-->
<selectfont>
<rejectfont>
<glob>*.dpkg-tmp</glob>
</rejectfont>
</selectfont>
<selectfont>
<rejectfont>
<glob>*.dpkg-new</glob>
</rejectfont>
</selectfont>
<!--
Load local system customization file
-->
<include ignore_missing="yes">conf.d</include>
<!-- Font cache directory list -->
<cachedir>/var/cache/fontconfig</cachedir>
<cachedir prefix="xdg">fontconfig</cachedir>
<!-- the following element will be removed in the future -->
<cachedir>~/.fontconfig</cachedir>
<config>
<!--
Rescan configuration every 30 seconds when FcFontSetList is called
-->
<rescan>
<int>30</int>
</rescan>
</config>
</fontconfig>

View File

@ -71,12 +71,18 @@ if [ -e /srv/autobuilder/valkyrie.yocto.io/ ]; then
zcat < install-tl-unx.tar.gz | tar xf -
cd install-tl-*/
./install-tl --scheme=small --texdir=${textooldir} --no-interaction
PATH=$PATH:${textooldir}/bin/x86_64-linux tlmgr install titlesec varwidth tabulary needspace upquote framed capt-of wrapfig fncychap gnu-freefont ctex latexmk
PATH=$PATH:${textooldir}/bin/x86_64-linux tlmgr install titlesec varwidth tabulary needspace upquote framed capt-of wrapfig fncychap gnu-freefont ctex latexmk nimbus15
popd
fi
PATH=$PATH:${textooldir}/bin/x86_64-linux
fi
# Provide our own fonts.conf path to make fonts installed with tlmgr available
# system-wide. It will pick up the fonts.conf file in this directory.
# This is then used by rsvg-convert to pick up the Nimbus font when converting
# files.
export FONTCONFIG_PATH="$scriptdir/docsfontconfig"
# Getting the old docbook built docs from an archive. Not rebuilding them.
docbookarchive_localpath=${sharedir}/cluster-downloads-cache/`basename ${docbookarchive_url}`
if [ ! -e ${docbookarchive_localpath} ]; then