As mentioned by @t-bltg in a comment, Ghostscript now comes with a ps2pdf
command which will embed missing fonts automatically.
ps2pdf -sFONTPATH="." in.pdf out.pdf
That should be all you need.
Troubleshooting
The above command presumes the necessary .ttf or .otf file is in the current working directory ("."
). If it is not, you can change .
to directory where the font file lives. For example:
ps2pdf -sFONTPATH="~/.local/share/fonts/" input.pdf output.pdf
(Note, you must specify a directory, not a font file.)
Make sure that the fontname the PDF is looking for is the same as the name embedded in the font file. For example, if the PDF wants a font named "Fantasy Bold", but the font file defines a font named "Fantasy" or "Fantasy Bold Neue LT Pro", this method will not work.
Bonus: The 14 type families
Even without specifying FONTPATH, Ghostscript knows about the 14 standard Postscript Level 2 fonts, including their old names. For example, modern systems sometimes do not render "New Century Schlbk" correctly because they expect "New Century Schoolbook". A simple ps2pdf in.pdf out.pdf
solves the problem.