class HexaPDF::Font::Type1::PFBParser
Parses files in the PFB file format.
Note that this implementation isn't a full PFB parser. It is currently just used for extracting the font encoding.
Public Class Methods
encoding(data) → encoding
click to toggle source
Parses the PFB data given as string and returns the found Encoding
.
# File lib/hexapdf/font/type1/pfb_parser.rb, line 54 def self.encoding(data) enc = Encoding::Base.new ss = StringScanner.new(data) if ss.skip_until(/\/Encoding\s+\d+\s+array.+?(?=\bdup\b)/m) while ss.skip(/dup\s+(\d+)\s+\/(\w+)\s+put\s+/) enc.code_to_name[ss[1].to_i] = ss[2].intern end elsif ss.skip_until(/\/Encoding\s+StandardEncoding\s+def/) enc = Encoding.for_name(:StandardEncoding) else raise HexaPDF::Error, "Unknown Type1 encoding" end enc end