I am trying to export my figure as a PDF. I run into the problem that when I want to edit it (in this case by Graphic on macOS) that the font appears not to be found by the editor. My question is, how do I solve this? Can I 'install' the fonts used by matplotlib?
Example
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([0,1], [0,1])
plt.savefig('test.pdf')
This PDF looks fine in Preview:
But in the editor, it gives gibberish:
Failing solution
Setting
matplotlib.rc("pdf", fonttype=42)
(see this answer).
Partly working solution
What works is to install all matplotlib's fonts. I have followed this answer to find all matplotlib's ttfs, and installed them. This works and solves the problem.
But... This does solve the issues when LaTeX is enabled, by
import matplotlib
matplotlib.rcParams['text.usetex'] = True
How do I install the fonts that matplotlib uses now?
A solution here is to export as SVG. However, for some reason this takes ages on my system (see this bug).