class HexaPDF::Font::Type1::AFMParser


Parses files in the AFM file format.

Note that this implementation isn’t a full AFM parser, only what is needed for parsing the AFM files for the 14 PDF core fonts is implemented. However, if need be it should be adaptable to other AFM files.

For information on the AFM file format have a look at Adobe technical note #5004 - Adobe Font Metrics File Format Specification Version 4.1, available at the Adobe website.

How Parsing Works

AFM is a line oriented format. Each line consists of one or more values of supported types (string, name, number, integer, array, boolean) which are separated by whitespace characters (space, newline, tab) except for the string type which just uses everything until the end of the line.

This parser reads in line by line and the type parsing functions parse a value from the front of the line and then remove the parsed part from the line, including trailing whitespace characters.

Public Class Methods


Creates a new parse for the given IO stream.

parse(filename) → font_metrics
parse(io) → font_metrics

Parses the IO or file and returns a FontMetrics object.

Public Instance Methods


Parses the AFM file and returns a FontMetrics object.