Oh Snap! Fonts in Roman Times

Those looking for cats, iot killer robot security issues, or high level society issues, avert your eyes.

Fonts. There’s a lot of them. I understand people have strong emotional attachment to them, there’s the pro and con ComicSans group for example.

But generally, as an end user, you just want the doc to look like what the author had in mind. And sometimes they had a font you don’t, and send you a pdf. And you get some characters kind a scrunched together.

For me the culprit is usually Mac folk, you get something like:

$ pdffonts XXX.pdf 
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
RTMUUR+TimesNewRomanPS-BoldMT        TrueType          MacRoman         yes yes no      11  0
MWLGOQ+TimesNewRomanPS-ItalicMT      TrueType          MacRoman         yes yes no      12  0
ZYNEQH+TimesNewRomanPSMT             TrueType          MacRoman         yes yes no      10  0
MGHQLD+ArialMT                       TrueType          WinAnsi          yes yes yes      9  0

MacRoman. WinAnsi. Sure, just what the universe needed. In this case, the TimesNewRomanPS-BoldMT maps to the wrong thing.

$ fc-match TimesNewRomanPSMT
comic.ttf: "Comic Sans" "Regular"

So you can fix it

cat ~/.config/fontconfig/fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

  <match> 
    <test name="family"><string>TimesNewRomanPS</string></test>
    <edit name="family" mode="assign" binding="same">
      <string>Times New Roman</string>
    </edit>
  </match>

  <match> 
    <test name="family"><string>TimesNewRomanPSMT</string></test>
    <edit name="family" mode="assign" binding="same">
      <string>Times New Roman</string>
    </edit>
  </match>

Now, what if you are running your libreoffice (castro-office I am told by unreliable authorities) from a snap? Its got one more step:

 

$ cat ~/snap/libreoffice/current/.config/fontconfig/fonts.conf 
<fontconfig>
  <dir>/home/don/.fonts</dir>
  <dir>/snap/libreoffice/65/usr/share/fonts</dir>
  <dir>/usr/local/share/fonts</dir>
  <dir>/usr/share/fonts</dir>
  <include ignore_missing="yes">/home/don/.config/fontconfig/fonts.conf</include>
  <include ignore_missing="yes">/home/don/.config/fontconfig/conf.d</include>
  <include ignore_missing="yes">conf.d</include>
  <cachedir prefix="xdg">fontconfig</cachedir>
  <cachedir>/home/don/.cache/fontconfig</cachedir>

</fontconfig>

see how I included my home dir .config/fontconfig/… stuff?

Next time you have to affix your John Hancock to a dock, use LibreOffice, and, if a font is missing, you’ll find this blog post and thank me.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *