This tutorial will show you how to extract font from a PDF file using Fontforge.
- A brief outline on the limitations regarding font extraction.
- Then we’ll go through an example where a partial font can be extracted.
- Followed by a second example where no font can be extracted.
i. You can download Fontforge for Windows, Mac, or Linux from here.
ii. The documents used in this tutorial are Elements of Typographic Style v3 – Extract and FontNaming-kltf.
iii. This tutorial is shown on a Windows 10 computer with Fontforge version 03142020.
iv. Fontforge does crash, so save often.
The following factors need to be considered when using Fontforge to extracts glyphs from a PDF;
Not all PDF documents can be read by Fontforge, because PDF documents can have restrictions, formatting peculiarities, embedded font, glyphs as pictures or some other configuration.
Sometimes when a font is embedded into a PDF it will only contain the glyphs used.
a) For example, if the PDF document you are trying to extract from does not contain the letter ‘Z’, then that letter will not be present.
Where all the glyphs are present in the PDF document, Fontforge may not extract them all.
a) This could be down to Fontforge’s code capabilities, the PDF format, it’s subsetting and optimization, locked or embedded PDF settings, or perhaps a little of both.
Most PDFs which are online, only embed subsets of the font and not the full font.
a) Extracting a subset of a font is only useful in a very limited scope, if at all.
When processing your extraction, Fontforge may display error dialogue boxes.
a) If there are errors in the file, you can choose to ignore them or save the file and edit them.
b) Most of the errors can be fixed automatically if you click “Fix” enough times.
With this knowledge, we’ll begin with an example that produces a partial font extraction.
Start by opening Fontforge, and on the first dialogue box,
a) click on the button next to ‘Filter’,
b) Select ‘Extract from PDF’ from the list,
c) Then, locate and select your PDF file,
d) Click ‘OK’.
Be aware that completing step c) before b) will not show any PDF file to select. You must complete step b) before c) for PDF files to be recognized.
If Fontforge is able to detect glyphs from the PDF, a dialogue box called ‘Pick a font’ will pop up listing the fonts detected within the PDF.
a) Select your preferred font and click ‘OK’.
You’ll be taken to ‘Font View’ where you can see the extracted glyphs.
From here you can either,
a) abandon the whole idea,
b) go ahead with the glyphs that have been extracted, or
c) try another PDF document.
To view, only the cells which have glyphs,
a) click on ‘Encoding>Compact’
With only the extracted glyphs visible, you’re now in a position to decide what to do next.
To be able to view all the extracted glyphs, neatly on screen, I’ll go ahead, and delete all the cells where the glyph is represented as a ‘square’.
And to hide these empty glyphs I’ll need to go back and,
a) click on ‘Encoding>Compact’ which will expand the table, then
b) repeat this action by clicking on ‘Encoding>Compact’.
For the next example, I repeated the same steps above only selecting a different PDF file, ‘FontNaming-ktlf.pdf’.
On this occasion, Fontforge is not able to read the PDF. In this situation Fontforge displays two (2) pop up dialogue boxes outlining the reason why.
a) The dialogue box advises that the font is encrypted and cannot be read.
As a result, there’s nothing more that can be done on this PDF to extract it’s font using Fontforge.
That brings us to the end of this tutorial.
I hope this tutorial has been of assistance and you can put some of the information to good use when extracting fonts from a PDF.