26
03
2008
Extracting fonts from PDF files
Posted by: jason in code, Internet, Linux, tags: convert, fontI stumbled across a font I wanted to use in a personal project. But it was in a PDF file. I found that this guy knew the steps to extract them and install the font on your windows box.
To summarize:
- Use linux (at the moment Ubuntu 7.10)
- Install fontforge (
~$ sudo apt-get install fontforge) - Convert your PDF to PostScript via
~$ pdftops pdffilename.pdf- this step creates files named
pdffilename.ps
- this step creates files named
- Open the PostScript file in your favourite editor –
~$ gedit pdffilename.ps - Find the following and extract everything between the lines with
BeginResourceandEndResource(excluding the Being/EndResource lines):
%%BeginResource: font CIKHFG+Schoensperger-ModifiedSave the extracted portions as with a pfa extension (there may be more than one section, so 1.pfa, 2.pfa … n.pfa)
%!FontType1-1.0: CIKHFG+Schoensperger-Modified
...
%%EndResource - Open the pfa files in fontforge until you find the desired font
~$ fontforge 1.pfa - Reencode the font as Latin1 (Encoding – Reencode – Latin1)
- Compact the font (Encoding – Compact).
- Adjust the garbled font name (Element – Font Info – Names).
- Generate a TrueType or PostScript Type1 font to your liking (File – Generate Fonts).