How to config Font substitution in poppler

Solution 1:

The page you mentioned saved me, thanks! Here is how:

As they indicate, what is needed is to configure fontconfig. I can't be sure for Ubuntu, but for Debian this means creating or editing this file :

/etc/fonts/local.conf

For the font substitution, you just need to include something like this example:

<alias>
    <family>Helvetica</family>
    <accept><family>Nimbus Sans L</family></accept>
</alias>

Where the Helvetica family would be substituted by the 'Nimbus Sans L' family.

To check that it works, you may use a PDF file containing e.g. Helvetica, and type:

pdffonts -subst <yourfile>.pdf

This will list the fonts substitutions. In my case, it worked just fine, with poppler now doing the right substitution.

Solution 2:

For Fedora, I created ~/.config/fontconfig/fonts.conf with following content:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
 <test name="family">
  <string>Helvetica</string>
 </test>
 <edit name="family" mode="prepend" binding="strong">
  <string>Liberation Sans</string>
 </edit>
</match>
</fontconfig>

It worked fine, tested with fc-match Helvetica and pdffonts -subst <yourfile>.pdf

I recommend the arch linux wiki for more font configuration info.