27/11/2015

Bunched up fonts in printing (from Okular)

Left side: This is how it looked in Okular. Right side: This is how it was printed. Solution courtesy of  ubuntuforums.org.
Pull up the "Fonts" tab in File->Properties… and look for non-embedded fonts in the document. In this case, Helvetica is substituted wrongly.
Font substitutions are handled in ~/.config/fontconfig/fonts.conf (on (K)ubuntu, that is). I added a new match tag to the end of the file (MS core fonts are installed, so I put in Arial, if not, find a free Helvetica/Grotesk):
 <match target="pattern">
  <test qual="any" name="family"><string>Helvetica</string></test>
  <edit name="family" mode="assign" binding="same"><string>Arial</string></edit>
 </match>
</fontconfig>


Afterwards, I ran fc-cache from a shell and checked whether the substitution was correct:
$ fc-cache 
$ fc-match Helvetica 
Arial.ttf: "Arial" "Normal"

Note: I didn't delve into why the substitution went wrong. Tex Gyre Hero actually seems to be working Helvetica substitute, and the weird bunching showed up all over the printout, not just in the sans serif parts. Whatever, it worked.

Note2, January 2024:

Another reason for misidentified fonts is if the font name encoded in the TTF file is different. In that case, changing it to what Okular expects works as well.  See thisHowTo and  handy python script provided by David Condrey on Superuser.

No comments: