So, my first blog article. Exciting. This is what inspired me to make this website a blog: Putting helpful things out on the internet that I have not found elsewhere.

TL;DR: Just print the PDF file via OSX Preview to a PDF if you want to get rid of Type 3 fonts in PDFs and are in a hurry.

The Problem

Recently, our paper on an optimistic sketching architecture for FPGAs was accepted at PVLDB. Sweet. However, the proceedings chairs were not quite happy with it. In particular, we were told:

Chairs:

(b) Please remove any Type 3 fonts you have in the PDF.

Huh, what’s that? Never heard of those. Turns out that is an outdated format for fonts that somehow ended up in my camera ready. How did that happen?

The Culprit

I have been using Matplotlib with Pandas for while now to create my plots in Jupyter notebooks. I generate PDFs and include them in the paper. Never had a problem with it. Now, unfortunately, I found those Type 3 fonts in my plots and in my manuscript (Adobe Viewer: File, Properties, Fonts).

Type 3 fonts, sitting in PDF files, not paying any rent.

The Clean Solution

After a little googling, I found that Matplotlib for some reasons uses Type 3 fonts by default. You can tell it to use a different font in the imports:

import matplotlib.pyplot as plt
plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42

Thanks to Jamie Oaks for his blog post, who had the same problem back in 2014. And indeed, the type 3 fonts are replaced by TrueType fonts, if you do that.

And now that we know this solution, we can just replot everything, and are good, right? We obviously have our stuff together and did not spread our plots over 1000 different notebook in different versions which would make it a pain to regenerate all plots and move them to the Latex project. Right? RIGHT?!

The Quick Solution

I swear, I was able to use the other solution because I had my stuff together. However, I was also in a hurry and would have appreciated a quick solution.

I got curious why I never encountered the issue even though I had been using Matplotlib in several publications. Turns out, I did one thing differently: I previously used a popular trick to embed fonts in PDFs which is mandatory for publications: I just printed the PDF file via OSX Preview (Print -> Save as PDF). This time I used a different service. Turns out, it did not feel responsible for dealing with Type 3 fonts.

So, the quick solution is: OSX Preview -> Print -> Print to PDF. The plots will look just as they did before, but the Type 3 fonts are gone. A couple of weird fonts will pop up in Acrobat Reader, but they are proper TrueType fonts. Boom. Takes less than five seconds.

The Non-Solution

A friendly person on the Internet suggested to use the convert tool from ImageMagick to get rid of Type 3 fonts.

convert in.pdf out.pdf

Unfortunately, the plots looked like blurry bitmaps which is not what I signed up for.

By Martin

Related Post

Leave a Reply

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