Next: Font Metrics, Previous: Introduction, Up: PFF2 Font File Format [Contents][Index]
A file section consists of a 4-byte name, a 32-bit big-endian length (not including the name or length), and then length more section-type-specific bytes.
The standard file extension for PFF2 font files is .pf2.
File type ID (ASCII string). This must be the first section in the file. It has length 4 and the contents are the four bytes of the ASCII string ‘PFF2’.
Font name (ASCII string). This is the full font name including family, weight, style, and point size. For instance, "Helvetica Bold Italic 14".
Font family name (ASCII string). For instance, "Helvetica". This should be included so that intelligent font substitution can take place.
Font weight (ASCII string). Valid values are ‘bold’ and ‘normal’. This should be included so that intelligent font substitution can take place.
Font slant (ASCII string). Valid values are ‘italic’ and ‘normal’. This should be included so that intelligent font substitution can take place.
Font point size (uint16be).
Maximum character width in pixels (uint16be).
Maximum character height in pixels (uint16be).
Ascent in pixels (uint16be). See Font Metrics, for details.
Descent in pixels (uint16be). See Font Metrics, for details.
Character index. The character index begins with a 32-bit big-endian unsigned integer indicating the total size of the section, not including this size value. For each character, there is an instance of the following entry structure:
If equal to 000 binary, then the character data is stored uncompressed beginning at the offset indicated by the character’s offset value.
If equal to 001 binary, then the character data is stored within a compressed character definition block that begins at the offset within the file indicated by the character’s offset value.
A marker that indicates the remainder of the file is data accessed via the character index (CHIX) section. When reading this font file, the rest of the file can be ignored when scanning the sections. The length should be set to -1 (0xFFFFFFFF).
Supported data structures:
Character definition Each character definition consists of:
uint16be
.
uint16be
.
int16be
.
int16be
.
int16be
.
The length of the bitmap data field is (width * height + 7) / 8 using integer arithmetic, which is equivalent to ceil(width * height / 8) using real number arithmetic.
It remains to be determined whether bitmap fonts usually make all glyph bitmaps the same height, or if smaller glyphs are stored with bitmaps having a lesser height. In the latter case, the baseline would have to be used to calculate the location the bitmap should be anchored at on screen.
Next: Font Metrics, Previous: Introduction, Up: PFF2 Font File Format [Contents][Index]