Skip to content

Instantly share code, notes, and snippets.

@tiagosr
Created February 19, 2011 17:35
Show Gist options
  • Save tiagosr/835212 to your computer and use it in GitHub Desktop.
Save tiagosr/835212 to your computer and use it in GitHub Desktop.
Truetype header struct description
typedef int32_t Fixed;
typedef int16_t FWord;
typedef struct
{
Fixed Table; // version number 0x00010000 for version 1.0.
Fixed fontRevision; // Set by font manufacturer.
uint32_t checkSumAdjustment; // To compute: set it to 0, sum the entire font as ULONG, then store 0xB1B0AFBA - sum.
uint32_t magicNumber; // Set to 0x5F0F3CF5.
uint16_t flags; // Bit 0 - baseline for font at y=0;
// Bit 1 - left sidebearing at x=0;
// Bit 2 - instructions may depend on point size;
// Bit 3 - force ppem to integer values for all internal scaler math; may use fractional ppem sizes if this bit is clear;
// Bit 4 - instructions may alter advance width (the advance widths might not scale linearly);
// Bits 5-10 - defined by Apple;
// Bit 11 - font compressed with Agfa MicroType Compression.
// Note: All other bits must be zero.
uint16_t unitsPerEm; // Valid range is from 16 to 16384
uint64_t created; // International date (8-byte field).
uint64_t modified; // International date (8-byte field).
FWord xMin; // For all glyph bounding boxes.
FWord yMin; // For all glyph bounding boxes.
FWord xMax; // For all glyph bounding boxes.
FWord yMax; // For all glyph bounding boxes.
uint16_t macStyle; // Bit 0 bold (if set to 1); Bit 1 italic (if set to 1)
// Bits 2-15 reserved (set to 0).
uint16_t lowestRecPPEM; // Smallest readable size in pixels.
int16_t fontDirectionHint; // 0 Fully mixed directional glyphs;
// 1 Only strongly left to right;
// 2 Like 1 but also contains neutrals;
// -1 Only strongly right to left;
// -2 Like -1 but also contains neutrals.
int16_t indexToLocFormat; // 0 for short offsets, 1 for long.
int16_t glyphDataFormat; // 0 for current format.
} truetype_head;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment