4

I need to read PFB files and extract Glyph information from it. I am unable to find the specification for the specific file. I have the Adobe Type1 font specification. But the PFB file is in binary format and i am unable to decode glyph information from it.

I have searched internet for the specification. But all i find is type 1 specification or glyph information. But i need instruction for how to retrieve the glyph information from PFB file.

Thanks in advance.

ohmantics
  • 1,799
  • 14
  • 16
Ramnish
  • 322
  • 3
  • 12

1 Answers1

1

On Linux/Unix you can find the pfb2pfa utility. This tool converts .pfb files to its ASCII representation (with .pfa suffix). Simply run:

pfb2pfa /path/to/input-fontfile.pfb /path/to/output-fontfile.pfa

You can also use Ghostscript to convert PFB font files to their PFA form.

First, save this content to a file and name it pfb2pfa.ps:

[ shellarguments {
  counttomark 2 eq {
    /pfa exch def /pfb exch def pop
    /in1 pfb (r) file def
    /in in1 true /PFBDecode filter def
    /out pfa (w) file def
    { in read not { exit } if out exch write } loop
    out closefile in closefile in1 closefile
    quit
  } {
    cleartomark (Usage: pfbtopfa input.pfb output.pfa) = flush
  } ifelse
  } {
  pop
} ifelse

Then, for Ghostscript on Windows run this command to convert fontname.pfb:

 gswin32c.exe ^
   -q ^
   -P- ^
   -dSAFER ^
   -dNODISPLAY ^
   -- ^
   "d:/path/to/pfb2pfa.ps" ^
   "f:/path/to/fontname.pfb" ^
   "e:/path/to/fontname.pfa"

For Ghostscript on Linux, Unix or Mac run this modified command:

 gs \
   -q \
   -P- \
   -dSAFER \
   -dNODISPLAY \
   -- \
   "/path/to/pfb2pfa.ps" \
   "/path/to/fontname.pfb" \
   "/path/to/fontname.pfa"

PFA fontfiles are readable PostScript code and my help you to achieve what you want...

If you are unlucky, they may contain a large section of eexec-encoded PostScript. This one you need to decode as well for the fully readable PostScript code....

Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • ... I was unlucky. Any tips on how do we decode the large section of eexec-encoded PostScript? – Pacerier Mar 21 '13 at 16:07
  • @Pacerier: Sorry, this is not *that* easy and quick to answer. I suggest you put it up as a new, separate question. This way I may find it again in a few days, when I've (hopefully) more time again. Or, if you are lucky, someone else will answer this one... – Kurt Pfeifle Mar 21 '13 at 20:39