Search code examples
fontsadobeembedded-fontsglyph

Need help finding specification document for Adobe Type1 binary font file - PFB


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.


Solution

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