wrong letter positioning and font in PDF form

I'm using Ubuntu 18.04 and filling out the SS-5 Social Security Administration form. However, some of the letters are wrongly positioned.

Evince 3.28.2-1:

evince screenshot (has kerning issues)

Okular 1.3.3 (Ubuntu version 4:17.12.3-0ubuntu1):

Okular screenshot (has kerning issues)

xpdf 3.04-7:

xpdf screenshot (has kerning issues)

mudpdf 1.12.0:

mupdf screenshot (no kerning issues)

The built-in PDF reader for Firefox 59.0.2:

firefox screenshot (no kerning issues)

The built-in PDF reader for Chromium 65.0.3325.181:

chromium screenshot (no kerning issues)

Here is the output of pdffonts:

$ pdffonts ss-5.pdf
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
IHPIKC+ArialMT                       CID TrueType      Identity-H       yes yes yes    824  0
ArialMT                              TrueType          WinAnsi          no  no  no     826  0
Arial-BoldMT                         TrueType          WinAnsi          no  no  no     828  0
CourierStd                           Type 1            WinAnsi          no  no  no     145  0
Helvetica                            Type 1            WinAnsi          no  no  no     197  0
MyriadPro-Regular                    Type 1            WinAnsi          no  no  no     198  0
ZapfDingbats                         Type 1            ZapfDingbats     no  no  no     199  0

I have already installed the ttf-mscorefonts-installer and poppler-data packages.

Here are my questions:

  • Can I change the font used for filling in the cells of the form?

    It seems like Evince and xpdf are using a variable-width font when they should be using a monospaced font, and maybe this is causing the positioning problem.

  • If I were to file a bug report, should I file it as a poppler issue, a fontconfig issue, or somewhere else?

Update: bug reports:

  • https://bugs.launchpad.net/ubuntu/+source/fontconfig/+bug/1824260

  • https://gitlab.gnome.org/GNOME/evince/issues/1127

  • https://gitlab.freedesktop.org/poppler/poppler/issues/753

Edit: The workaround from @xiota is perfectly functional. However, this is still a bug in poppler, because when the PDF viewer substitutes a different font due to the original not being embedded, the spacing in the XFA form should match the substituted font, not the original font. There is a pull request to fix this that is currently in progress. Poppler developer Tobias Deiminger (@haxtibal) described the approach in a different bug report:

The strategy there is, if a font is not embedded, gather and use metrics from the actual substitute font instead of metrics from PDF font descriptor or hardcoded ones.


Solution 1:

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


The problem you are observing is caused by incorrect font substitution. On my computer, CourierStd and ZapfDingbats are replaced with Ubuntu. That will obviously not render properly.

pdf font properties

To correct this:

  • Install fonts-urw-base35. This should correct the Dingbats and most other pdf font substitutions. However, CourierStd substitution is not fixed because it is not in the config files.

  • To correct CourierStd, 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>Courier Std</family>
        <accept>
        <family>Courier</family>
        </accept>
      </alias>
    
      <alias>
        <family>Courier Std</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:

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