Link
how-to-extract-fonts-from-pdf-in-fontforge

How to Extract Font From a PDF File Using Fontforge

This tutorial will show you how to extract font from a PDF file using Fontforge.

How this Tutorial Is Organized

  1. A brief outline on the limitations regarding font extraction.
  2. Then we’ll go through an example where a partial font can be extracted.
  3. 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.


Extracting Limitations

The following factors need to be considered when using Fontforge to extracts glyphs from a PDF;

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.


Partial Extraction

  1. With this knowledge, we’ll begin with an example that produces a partial font extraction.

  2. 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,

    open-fontforge-select-extract-pdf-font

    c) Then, locate and select your PDF file,
    d) Click ‘OK’.

    open-fontforge-select-file-extract-font-from-pdf

  3. 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.

  4. 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’.

    select-font-to-extract-from-list

  5. You’ll be taken to ‘Font View’ where you can see the extracted glyphs.

    displays-result-of-font-from-pdf-extraction

  6. 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.

  7. To view, only the cells which have glyphs,
    a) click on ‘Encoding>Compact’

    compact-view-of-extracted-glyphs

  8. With only the extracted glyphs visible, you’re now in a position to decide what to do next.

    compact-view-of-extracted-glyphs

  9. 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’.

    delete-empty-glyphs-from-extracted-fonts-from-pdf-in-fontforge

  10. 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’.

    repeat-compact-process-two-times-to-view-extracted-glyphs


No Extraction

  1. For the next example, I repeated the same steps above only selecting a different PDF file, ‘FontNaming-ktlf.pdf’.

  2. 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.

    warning-box-advising-font-cannot-be-read

    warning-box-advising-font-cannot-be-read-it's-encrypted

  3. 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.