Glyph Class vs Coverage Table in FontForge
In font design with FontForge, both glyph class definitions and coverage tables organize glyphs for OpenType layout features such as substitutions and kerning, but they perform fundamentally different roles in font architecture. A coverage table acts as an entry gate that identifies which specific glyphs trigger a lookup subtable, whereas a glyph class definition categorizes glyphs into distinct sets to apply shared rules across multiple characters simultaneously. Understanding this distinction is essential for building efficient, error-free OpenType features in FontForge.
What is a Coverage Table?
A coverage table is a low-level OpenType structure present in nearly every lookup subtable (such as GSUB for substitutions and GPOS for positioning). Its primary function is to define the exact set of glyphs to which a specific subtable applies.
When a text layout engine processes text, it checks the coverage table first. If a glyph is not listed in the coverage table, the engine immediately skips that subtable and moves to the next. The coverage table also assigns a unique "Coverage Index" (from 0 to n-1) to each covered glyph, which determines the order in which glyphs are processed and maps them directly to the corresponding positioning or substitution data.
In FontForge, coverage tables are often generated automatically when you specify the target glyphs in a lookup subtable, such as single substitutions or mark-to-base attachments.
What is a Glyph Class Definition?
A glyph class definition (ClassDef) partitions a collection of glyphs into numbered categories (Class 0, Class 1, Class 2, and so on). Unlike a coverage table, which merely provides a flat list of matching characters, a class definition labels glyphs so that an entire group behaves identically within a rule.
Classes are primarily used to simplify complex operations. For
example, in class-based kerning, you might assign all glyphs with round
left sides (like c, e, and o) to
Class 1, and glyphs with vertical stems (like b,
h, and k) to Class 2. Instead of writing
separate kerning pairs for every letter combination, you write a single
rule between Class 1 and Class 2. FontForge allows you to define these
classes manually or generate them based on visual metrics within the
Metrics and Lookups interfaces.
Key Differences Between the Two
- Primary Purpose: A coverage table determines if a subtable applies to an input glyph. A glyph class definition determines how a glyph is treated relative to other glyphs within that subtable.
- Data Organization: A coverage table maps Glyph IDs to sequential index numbers (0, 1, 2, ...). A class definition maps Glyph IDs to user-defined class values. Glyphs not explicitly assigned to a class automatically default to Class 0.
- Usage Context: Coverage tables are mandatory components of nearly all OpenType subtables to establish entry conditions. Glyph classes are optional design tools utilized inside specific subtable formats, such as class-based pair kerning (GPOS Format 2) or contextual chaining substitutions.
- Execution: Layout engines use the coverage table as an initial filter to optimize processing speed before any class-based lookups or matrix evaluations take place.