Font Tables Reference
This document provides a brief overview of major OpenType and AAT font tables supported by TypeShaper.
Required Tables
HeadTable
Font header containing basic metadata.
Key Fields:
unitsPerEm: number- Font design units per emflags: number- Font flagscreated: Date- Creation datemodified: Date- Last modified datexMin, yMin, xMax, yMax: number- Font bounding boxindexToLocFormat: number- Format of loca table (0 or 1)
MaxpTable
Maximum profile defining resource limits.
Key Fields:
numGlyphs: number- Number of glyphs in the fontmaxPoints: number- Max points in non-composite glyphmaxContours: number- Max contours in non-composite glyph
HheaTable
Horizontal header with typographic metrics.
Key Fields:
ascender: number- Typographic ascenderdescender: number- Typographic descenderlineGap: number- Line gapadvanceWidthMax: number- Maximum advance widthnumberOfHMetrics: number- Number of hMetric entries
HmtxTable
Horizontal metrics for each glyph.
Access via:
const advance = font.advanceWidth(glyphId);
const lsb = font.leftSideBearing(glyphId);CmapTable
Character to glyph mapping.
Access via:
const glyphId = font.glyphId(0x0041); // Unicode codepoint
const glyphId = font.glyphIdForChar("A"); // CharacterOpenType Layout Tables
GdefTable
Glyph definition table classifying glyphs.
Glyph Classes:
- Base - Base character
- Ligature - Ligature glyph
- Mark - Non-spacing mark
- Component - Component of ligature
Features:
- Glyph class definitions
- Attachment points
- Ligature caret positions
- Mark attachment classes
GsubTable
Glyph substitution table for character-to-glyph transformations.
Lookup Types:
- Single - One-to-one substitution
- Multiple - One-to-many substitution
- Alternate - One-to-one from alternatives
- Ligature - Many-to-one substitution
- Context - Context-dependent substitution
- Chaining Context - Extended context substitution
- Extension - Extension mechanism
- Reverse Chaining - Right-to-left substitution
Common Features:
liga- Standard ligatures (fi, fl)calt- Contextual alternatesccmp- Glyph composition/decompositionsmcp- Small capitalsswsh- Swash forms
GposTable
Glyph positioning table for layout adjustments.
Lookup Types:
- Single - Adjust single glyph position
- Pair - Adjust glyph pair (kerning)
- Cursive - Cursive attachment
- MarkToBase - Attach mark to base
- MarkToLigature - Attach mark to ligature
- MarkToMark - Attach mark to mark
- Context - Context-dependent positioning
- Chaining Context - Extended context positioning
- Extension - Extension mechanism
Common Features:
kern- Kerningmark- Mark positioningmkmk- Mark-to-mark positioningcurs- Cursive attachment
KernTable
Legacy kerning table (pre-OpenType).
Access via:
import { getKernValue } from "typeshaper";
const kern = getKernValue(font.kern, glyph1, glyph2);Variable Font Tables
FvarTable
Font variations defining variation axes.
Key Fields:
axes: VariationAxis[]- List of variation axesinstances: NamedInstance[]- Named instances
VariationAxis:
interface VariationAxis {
tag: Tag; // Axis tag (e.g., 'wght', 'wdth')
minValue: number; // Minimum value
defaultValue: number; // Default value
maxValue: number; // Maximum value
name: string; // Axis name
}GvarTable
Glyph variations for outline adjustments.
Usage:
const contours = font.getGlyphContoursWithVariation(glyphId, normalizedCoords);HvarTable
Horizontal metrics variations.
Features:
- Advance width deltas
- Left side bearing deltas
Access via Face:
const face = new Face(font, { wght: 700 });
const advance = face.advanceWidth(glyphId); // Includes HVAR deltaAvarTable
Axis variations for non-linear axis mappings.
Maps user coordinates to normalized coordinates for each axis.
MvarTable
Metrics variations for font-wide metrics.
Supported Metrics:
- Ascender, Descender
- Line gap
- Cap height, x-height
- Subscript/superscript metrics
Vertical Layout Tables
VheaTable
Vertical header (vertical writing systems).
Key Fields:
ascender: number- Vertical ascenderdescender: number- Vertical descenderlineGap: number- Vertical line gapnumberOfVMetrics: number- Number of vMetric entries
VmtxTable
Vertical metrics for each glyph.
VorgTable
Vertical origin for CJK fonts.
Color Font Tables
ColrTable
Color layered glyphs (COLRv0 and COLRv1).
Features:
- Simple color layers (v0)
- Gradient fills (v1)
- Transformations (v1)
- Compositing modes (v1)
Access:
import { hasColorGlyph, getColorLayers } from "typeshaper";
if (hasColorGlyph(font.colr, glyphId)) {
const layers = getColorLayers(font.colr, glyphId);
}CpalTable
Color palettes for COLR table.
Access:
import { getColor } from "typeshaper";
const color = getColor(font.cpal, paletteIndex, colorIndex);
// Returns { red, green, blue, alpha }SvgTable
SVG glyphs embedded in font.
Access:
import { hasSvgGlyph, getSvgDocument } from "typeshaper";
if (hasSvgGlyph(font.svg, glyphId)) {
const svg = getSvgDocument(font.svg, glyphId);
}SbixTable
Apple bitmap glyphs with alpha channel.
Features:
- PNG, JPEG, TIFF formats
- Multiple PPEM sizes
- Dupe glyph handling
Access:
import { hasGlyphBitmap, getSbixGlyphBitmap } from "typeshaper";
const bitmap = getSbixGlyphBitmap(font.sbix, glyphId, ppem);CBDT/CBLC Tables
Google color bitmap format.
Features:
- Multiple bitmap formats
- Embedded bitmaps at various sizes
AAT Tables
MorxTable
Extended morphing (Apple Advanced Typography).
Subtable Types:
- Rearrangement - Reorder glyphs
- Contextual - Context-dependent substitution
- Ligature - Ligature formation
- Non-contextual - Simple substitution
- Insertion - Insert glyphs
Usage:
// Automatically applied if GSUB not present
const shaped = shape(font, buffer);KerxTable
Extended kerning (AAT).
Features:
- Format 0: Ordered list of kerning pairs
- Format 1: State table kerning
- Format 2: Simple kern array
- Format 4: Control point kerning
- Format 6: Simple index kerning
TrakTable
Tracking (letter spacing) adjustments.
Access:
import { applyTracking } from "typeshaper";
const adjustment = applyTracking(font.trak, pointSize, tracking);FeatTable
Feature names for AAT features.
Usage:
import { getAllFeatures, getFeature } from "typeshaper";
const features = getAllFeatures(font.feat);Outline Tables
LocaTable
Glyph location table for TrueType outlines.
Maps glyph IDs to offsets in the glyf table.
GlyfTable
Glyph data for TrueType outlines.
Glyph Types:
- Simple - Single contour
- Composite - Multiple component glyphs
Access:
const contours = font.getGlyphContours(glyphId);
const bounds = font.getGlyphBounds(glyphId);CFF / CFF2 Tables
Compact Font Format (PostScript outlines).
- CFF - Static fonts
- CFF2 - Variable fonts
Access:
const contours = font.getGlyphContours(glyphId); // Works for both CFF and TrueTypeHinting Tables
FpgmTable
Font program executed once per font.
PrepTable
Control value program executed once per size.
CvtTable
Control value table with values used by instructions.
GaspTable
Grid-fitting and scan-conversion procedure.
Defines which size ranges use hinting vs. smoothing.
Other Tables
Os2Table
OS/2 and Windows metrics.
Key Fields:
- Weight class
- Width class
- Type flags
- Strikeout/underline metrics
- Unicode ranges
- Code page ranges
NameTable
Naming table with human-readable strings.
Name IDs:
- 0: Copyright
- 1: Font family
- 2: Subfamily
- 4: Full name
- 6: PostScript name
- 16: Typographic family
- 17: Typographic subfamily
PostTable
PostScript information.
Features:
- Glyph names
- Italic angle
- Underline metrics
- Fixed pitch flag
StatTable
Style attributes for variable fonts.
Features:
- Axis records
- Axis values
- Elidable axis value names
Usage:
import { getAxisRecord, matchAxisValue } from "typeshaper";
const axis = getAxisRecord(font.stat, 0);Table Access Pattern
All tables use lazy loading:
// Table is parsed on first access
const gdef = font.gdef; // Parses GDEF table
// Subsequent accesses use cached value
const gdef2 = font.gdef; // Returns cached table
// Check for table presence
if (font.hasTable(Tags.GSUB)) {
const gsub = font.gsub;
}