PDF font falls back to DejaVu Sans, need a monospace replacement

I have a PDF that features code fragments and it references Courier Std (which is not available on my system and I am not planning to buy it either). The problem is that in the Evince Document Viewer (3.18.2) this font is replaced by DejaVu Sans, which is not a monospace font and code that is note set in a monospace font is just hard to read. (the idiosyncratic kerning adjustment just makes it even harder).

I have installed the msttcorefonts in the hope that it might help, it does not. How can replace DejaVu Sans with a monospace font?

enter image description here

UPDATE: If I load the PDF in Firefox, the font gets correctly replaced by a monospace font.

1 Answer

This issue should be patched in the next version of Ubuntu (21.04). There is also an upstream fontconfig merge request #128 pending.


In the meantime, the following steps should help address some PDF font substitution problems:

  • Install fonts-urw-base35.

  • Create the file ~/.config/fontconfig/conf.d/10-pdf-aliases.conf with the following contents:

     <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "/etc/fonts/conf.d/fonts.dtd"> <fontconfig> <alias binding="same"> <family>CourierStd</family> <accept> <family>Courier</family> </accept> </alias> <alias> <family>CourierStd</family> <default><family>monospace</family></default> </alias> </fontconfig>

    Then run fc-cache (may not be necessary).

    You can add other font aliases to the file as needed.

See also:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like