Cap height 2026-11-05
The cap height is the reference height of ordinary unaccented capital letters above a text baseline. It describes uppercase letter design, while the x-height concerns the main lowercase body. A font ascent can reserve more space for accents or other tall forms than the cap height alone requires.
OpenType records a nominal cap height in the sCapHeight field of its OS/2 metrics table, in font units. The metric is an approximation for the uppercase design, so taking the largest ink bounding box among every uppercase glyph need not give the intended value.[ref]
For a hypothetical computer font with cap metric 700 and 1000 font units per em, the reference height at 18 pixels per em is 12.6 pixels before grid fitting. An ascent metric of 800 font units would instead reserve 14.4 pixels above the text baseline. These describe different geometric features of the same design.
Aligning a capital heading against an icon can therefore require choosing which reference matters: the text baseline, the nominal cap height, or a measured ink bounding box. Keeping those quantities separate makes the alignment rule reproducible.
Computer font Created 2026-10-13 Updated 2026-11-05
A computer font stores data used to display text: glyph descriptions, spacing measurements, and mappings from text characters to glyphs. An OpenType computer font organizes these into separate tables. Its cmap table maps encoded text characters to default glyph indices; other tables can specify subsequent substitutions and positioning.
The separation permits several representations of a glyph. An outline font stores scalable boundaries, whereas a computer font can also contain images already sampled into pixels. The rendering system uses the selected representation and placement data to produce the visible text. A file containing glyph outlines therefore supplies more than a list of Unicode numbers.[ref]
Em (typography) 2026-11-05
An em is a nominal typographic length set by the current font size. At a font size of typographic points, one em is typographic points long.[ref] A scalable computer font describes its geometry relative to this scale. In OpenType, unitsPerEm specifies how many font units make one em.[ref]
Suppose one em contains 2048 font units. A design length of 1024 font units is half an em. At a font size of 12 typographic points, that length is 6 typographic points; at 18 typographic points, it is 9 typographic points. The stored coordinate has not changed; the scale has.
The word em does not require the glyph for “M” to be exactly one em wide. Nor is an em the measured ink height of every glyph: a shape can occupy only part of the nominal square or extend beyond it.[ref] Glyph advances, left side bearings and right side bearings must consequently be read from the computer font's metrics rather than inferred from the em alone.
Font ascent 2026-11-05
The font ascent is an upward metric measured from a text baseline and used when allocating vertical space for a font. It describes the font's layout metrics as a whole, rather than the visible ascender of one particular glyph. A short letter, a tall letter and an accented form can therefore share the same font ascent while having different ink bounding boxes.[ref]
Suppose a computer font has a chosen font ascent of 800 font units and 1000 font units per em. At 20 pixels per em, the scaled upward metric is 16 pixels. This calculation allocates a reference extent; it does not assert that the letters being drawn actually reach 16 pixels above the text baseline.
The field used must be stated. OpenType provides ascender in hhea and sTypoAscender in OS/2, while some older layout paths use other metrics. The sTypoAscender, sTypoDescender and sTypoLineGap fields are intended to work together for typographic line spacing. Their ascent-minus-descent need not equal unitsPerEm.[ref]
Combining a font ascent with the corresponding font descent and font line gap gives a consistent basis for choosing line height. Mixing fields chosen under different conventions can instead change the spacing even when the nominal font size is unchanged.
Font descent 2026-11-05
The font descent supplies the below-text baseline part of a font's vertical layout metrics. It must be distinguished from the descender of an individual glyph. The coordinate convention also matters: a downward extent can be represented as a negative coordinate in a system whose vertical axis points upward, or as a positive distance in another API.[ref]
For example, a signed descent font units represents a downward extent font units. With 1000 font units per em and 20 pixels per em, its magnitude scales to 4 pixels. Calling that a negative height would confuse the coordinate with the distance being allocated.
Using a signed descent, an ascent and a font line gap in the same font units gives
Equivalently, if is the positive downward extent, the same line height is . This is the elementary typographic spacing model; the rendering system's choice of metrics must still be respected.[ref]
A computer font can contain several descent-related fields. For example, OpenType's hhea header stores a typographic descender; an application must not infer the sign and purpose of every other API field merely from the word descent.[ref]
Font line gap 2026-11-05
A font line gap is a font-wide metric giving an additional spacing allowance to combine with font ascent and font descent. For an elementary default line-spacing calculation using signed descent ,
where is the ascent and the font line gap. OpenType's sTypoLineGap is intended to be used with the matching sTypoAscender and sTypoDescender fields.[ref]
Suppose the chosen metrics are , and font units. The default spacing is 1100 font units. With 1000 font units per em at 18 pixels per em, that is 19.8 pixels between text baselines.
The stored font line gap provides an input to a spacing decision. An application can instead request a different line height, and CSS leading is then calculated from that requested height and the selected metrics. Nor does the font line gap measure the visible blank strip between every pair of lines: the ink bounding boxes vary with the particular glyphs. The line height diagram shows this distinction with schematic ink inside larger font-wide metric regions.
Font unit 2026-11-05
A font unit measures distances in a computer font's design coordinates. If one em contains font units, a coordinate difference represents of an em. OpenType stores in the unitsPerEm field of its font-header table; its permitted range is 16–16384.[ref]
The design coordinate is independent of a particular screen. Before grid fitting, an unrotated uniform scale with pixels per em sends a horizontal length to
For example, and send a length of 512 font units to 3 pixels. Doubling the requested font size doubles that ideal geometric length without changing the stored outline.
A font unit is consequently not itself a pixel. Grid fitting can further change a scaled outline or its glyph advance to suit the pixel grid. Nor does the height of every visible glyph equal one em: the em fixes a scale, while individual glyphs have their own bounding boxes.
Glyph advance 2026-11-05
A glyph advance is the displacement of the logical pen position after a glyph is processed. In horizontal layout its main component is often called the advance width. The OpenType horizontal-metrics table records an advanceWidth in font units, together with a left side bearing.[ref]
The advance need not equal the width of the visible glyph's bounding box. A spacing text character can select a glyph with a positive advance and no visible outline. Conversely, a drawn shape can extend beyond its nominal advance, or a positioned accent can have a zero advance. The geometry of the ink and the progression of the logical pen therefore require separate data. In a simple horizontal metric, the advance is the left side bearing plus the ink width plus the right side bearing; overhangs can make a bearing negative.
For a hypothetical pair with advances 600 and 600 font units, a pair adjustment of minus 80 gives a total advance of 1120 font units. The second origin moves 80 font units left of its unadjusted position. No glyph outline needs to change for this kerning operation. The final layout can therefore have different advances from the default values stored for isolated glyphs.
Glyph index 2026-11-05
A glyph index is a numerical identifier for a glyph inside a particular computer font. It identifies an entry in that font's own glyph collection, rather than a Unicode code point. In an OpenType computer font, the cmap table maps character codes to default glyph indices; unavailable characters map to index zero, whose special .notdef glyph indicates missing coverage.[ref]
For a hypothetical example, one computer font might map U+0041 to index 37 while another maps the same character A to index 9. Both can display the correct letter. Carrying index 37 from the first computer font into the second can select an unrelated form. A later glyph substitution can also change the selected glyph index while leaving the underlying text characters unchanged. This distinction matters in rendering caches and when exchanging shaped text between systems.
Glyph positioning 2026-11-05
Glyph positioning assigns locations to the glyphs selected during text shaping. It specifies how each glyph is placed and how the logical pen position progresses through the text. A text baseline supplies a common reference for placing the shapes. An OpenType GPOS table can adjust horizontal and vertical placement, glyph advances and attachment between selected glyphs.[ref]
A simple coordinate model separates the two effects. Let be the pen position, a placement offset and the glyph advance. Draw glyph with its origin at
then update the logical position by
Changing moves the current shape; changing moves the starting position of subsequent shapes.
For example, a combining character can select an accent glyph that must be positioned above an earlier base glyph. The accent's placement and its glyph advance answer different questions. Kerning similarly changes spacing according to context, while glyph substitution changes which forms are selected. These choices precede the rasterization of the placed outlines into pixels.
Glyph substitution 2026-11-05
Glyph substitution replaces selected glyph indices by other glyph indices while laying out text. In OpenType, the GSUB table specifies these replacements after the default character-to-glyph index mapping. A substitution can replace one glyph by another, several by a typographic ligature, or one by several; its application can depend on surrounding glyphs.[ref]
For a hypothetical computer font, suppose f and i initially select indices17 and23. A matching ligature rule could replace the pair by index91. These numbers belong to that particular computer font; they do not change the stored Unicode sequence into code point91. The example also shows why substitution differs from kerning: replacing the pair selects a new shape, whereas adjusting the pair's positions can retain both original shapes.
Lookup order matters when one substitution creates or removes the input pattern for a later substitution. Text shaping must therefore interpret the applicable OpenType rules, rather than independently choosing a default glyph for each text character.
Kerning 2026-11-05
Kerning adjusts spacing for particular combinations of glyphs. For example, the open region beneath an overhanging “T” can allow a following round glyph to be placed closer than a uniform spacing rule would suggest. The OpenType kern feature provides context-dependent adjustments for horizontal layout; the separate vkrn feature addresses vertical layout.[ref]
In a simplified horizontal pair model with default glyph advances and adjustment , the total advance is . A negative reduces the gap for that pair, while a positive increases it. The numerical value depends on the computer font, its scale and the applicable layout rules; a particular letter pair does not have one universal adjustment.
Kerning is one application of glyph positioning. It can preserve the same glyph indices while changing their arrangement. A typographic ligature instead selects a combined form through glyph substitution. Selecting an appropriate form and placing it well are complementary parts of text shaping.
Left side bearing 2026-11-05
In a simple unpositioned horizontal layout, the left side bearing is the signed distance from a glyph's pen position to the left edge of its ink bounding box. Put the logical origin at and call the left ink edge . Then . A positive value leaves space before the ink; a negative value means that the ink overhangs the origin.[ref]
For example, a glyph whose ink occupies and whose glyph advance is 600 font units has left side bearing 40, ink width 500 and right side bearing 60. These are default metrics; subsequent glyph positioning can change the rendered arrangement.
Figure 1. . Original schematic of a hypothetical glyph with advance 600 font units. The rectangle is its ink bounding box, not a reconstructed outline from a particular computer font. Details.
OpenType's horizontal-metrics table supplies the left side bearing and glyph advance. One must not assume that every outline's stored xMin is already the left side bearing: the outline's own coordinate origin and the metrics' logical origin need not coincide in every supported format.[ref]
OpenType 2026-11-05
OpenType is a table-based computer font format separating glyph representations, character mapping, measurements, naming metadata and optional layout rules. Its cmap table selects default glyph indices for encoded text characters; substitution and positioning tables support more elaborate text shaping.
An OpenType computer font can contain TrueType outlines or Compact Font Format outlines, and the specification also provides for bitmap and other glyph representations. The file format therefore does not prescribe a single kind of outline geometry. Extensions such as .ttf and .otf are useful conventions, but the actual table contents determine the available representation.[ref]
This organization lets one system answer separate questions: which glyph represents this text, how much space should it occupy, and how should it be drawn at this size? A language's contextual forms can change the first answer without changing the original Unicode text.
Right side bearing 2026-11-05
The right side bearing measures the signed gap from the right edge of a glyph's ink bounding box to the point specified by its default horizontal glyph advance. If the origin is , the advance is , and the ink edges are , then
Thus the advance splits into a left side bearing, an ink width and a right side bearing. OpenType uses this relation to derive the right side bearing from the horizontal metrics and outline bounds.[ref]
For the hypothetical ink interval and advance 600 font units, the right side bearing is 60 font units. If a different glyph extends to with the same advance 600, its right side bearing is font units: ink crosses the next nominal origin. A negative bearing is therefore meaningful rather than an invalid width.
These are metrics of an individual default glyph. Kerning and other glyph positioning rules can change the actual gap between adjacent shapes, so the right side bearing alone does not determine the visual spacing of a whole run.
Text baseline 2026-11-05
A text baseline is the reference line used to align glyphs in a run of text. It supplies a placement reference rather than the edge of every visible shape. In a horizontal coordinate system with the baseline at , a descender can extend below the line, while an ascender extends above the main body of a lowercase letter. Aligning ink bounding boxes at their bottom edges would therefore fail to align the writing.[ref]
The reference depends on the writing system and layout. OpenType distinguishes an alphabetic baseline (romn), a hanging baseline (hang) and a mathematical baseline (math), among others. The last is the reference about which mathematical forms are centred; it need not coincide with the alphabetic baseline. Vertical layout also requires an appropriate baseline convention.[ref]
For a simple horizontal run, start the logical pen position at on the chosen text baseline. A glyph advance moves the next pen position to . A vertical placement adjustment can move an accent glyph while leaving that baseline and the subsequent logical positions intact. This distinction lets glyph positioning align the run while placing individual forms precisely.
TrueType 2026-11-05
TrueType is a computer font technology whose glyph outlines use quadratic Bézier curves and straight segments. The stored coordinates describe a scalable design in font units. Rendering scales that geometry to the requested size and applies rasterization to obtain pixels.
At small display sizes, geometrically accurate scaling can place important strokes between pixels. Font hinting supplies instructions that adjust the scaled outline relative to the output grid, helping preserve recognizable strokes and spacing. A small capital letter can therefore require more than shrinking a large image: the useful result depends on the relation between its geometry and the pixel grid.[ref]
TrueType outlines can be stored in an OpenType computer font. The outline technology and the larger table-based file format describe different layers of the same rendering system.
Typeface 2026-11-05
A typeface is a coordinated visual design for written forms. It can include related regular, bold and italic styles; a computer font supplies digital data implementing a particular selection or instance of that design. Thus choosing a typeface and choosing the file format used to store its glyphs are different decisions.
For a hypothetical family “Example Sans”, regular and bold styles can share a typographic family name while having different subfamily names. OpenType records this distinction in its naming table: name IDs 16 and 17 identify the typographic family and subfamily. Older family-name fields can group styles differently for application compatibility, so a filename alone is not a reliable account of the intended family.[ref]
Typographic ligature 2026-11-05
A typographic ligature combines two or more written forms into a single glyph. A familiar example is an “fi” shape joining the end of “f” to the following “i”. Its use can improve spacing or avoid a collision between the two shapes.
An OpenType shaping system can first map the separate text characters “f” and “i” to their default glyph indices, then apply a glyph substitution that replaces that pair by one ligature glyph index. The stored text need not be replaced by a special ligature character. Selection and copying can therefore preserve the original two-character sequence even though the display contains one glyph.[ref]
A typographic ligature also need not be produced merely by moving two glyphs closer together: substitution changes the selected form, whereas positioning changes where selected forms are drawn.