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]Font Header Table by Microsoft. head table, unitsPerEm
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]
CSS Fonts Module Level 4 by W3C. Section2.5, note about arbitrary glyph ink bounds relative to the EM box
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 metric 2026-11-05
A font metric is a numerical measurement used to position text from a computer font. Measurements include glyph advances, glyph bearings, bounding boxes and face-level quantities such as font ascent, font descent and font line gap. These describe both logical movement and the geometry of the visible shapes.[ref]
For a horizontal example, put the pen position at , let a glyph have advance 12, and let its ink extend from to . Its ink width is , while the next pen position is . The negative left glyph bearing describes an overhang; it does not imply a negative glyph advance.
A separate example illustrates vertical conventions. With font ascent , signed descent and font line gap , the metric-based baseline separation isSome font formats store the descent magnitude with the opposite sign, so the convention must be checked before using the formula.[ref]
Glyph Metrics in the FreeType documentation. §2: ascent, signed descent and linespace formula
These measurements inform layout before rasterization determines the actual pixels. Font-size adjustment 2026-11-05
A font-size adjustment rescales a font to preserve a selected visual metric when the design changes. Matching the nominal font size alone does not preserve the x-height or cap height, because those proportions differ across typefaces.
The x-height calculation gives a direct rule. If a requested scale and desired lowercase ratio should be matched by a fallback design with ratio , useFor example, matching at 20 pixels per em with a fallback ratio requires 22 pixels per em. Both designs then have ideal lowercase body height 11 pixels. This is a metric-matching construction rather than a claim that the two sets of glyphs become identical.
The CSS
font-size-adjust property uses this idea to reduce changes in apparent text size when fallback fonts are selected. Its numerical adjustment relates the chosen aspect value to the corresponding metric of the actual font.[ref]Changing scale also changes glyph advances, left side bearings and other distances. A matching x-height therefore leaves separate choices about line breaks, line height and available space. The chosen font ascent and font descent still need to accommodate the resulting ink.
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]Font Header Table by Microsoft. head table, unitsPerEm
The design coordinate is independent of a particular screen. Before grid fitting, an unrotated uniform scale with pixels per em sends a horizontal length toFor 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]Horizontal Metrics Table by Microsoft. Horizontal metrics, hMetrics records and advanceWidth
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 bearing 2026-11-05
A glyph bearing is a signed offset locating a glyph's ink relative to the reference used for layout. In a simple horizontal metric, the left side bearing measures the offset from the pen position to the left ink edge, and the right side bearing measures the remaining distance from the right ink edge to the advance endpoint.[ref]
Glyph Metrics in the FreeType documentation. §3: bearings and advances
Put the origin at , the glyph advance at , and the ink edges at . ThenFor , and , the bearings are and 3, while the ink width is 11. The negative left bearing records an overhang across the origin. The next nominal pen position remains at .
Ink bounds, side bearings and glyph advance
. Original horizontal schematic with an invented outline: left ink edge -2, right ink edge 9, advance 12. The plotted shape is not copied from a font. Horizontal measurements are in consistent arbitrary units. Details.These are measurements of a default horizontal arrangement. Subsequent glyph positioning and kerning can change the rendered relationship between neighbouring glyphs. The reference point and axes must also be checked when applying bearing conventions to vertical layout.
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]
Glyph Positioning Table by Microsoft. Overview, ValueRecords and positioning/attachment lookup types
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 atthen update the logical position byChanging 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.
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]Kerning in the OpenType Registered Features by Microsoft. Feature kern: function, To example and relation to vkrn
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]
Glyph Metrics in the FreeType documentation. Section 3: bearings and advances
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.
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]Horizontal Metrics Table by Microsoft. Opening discussion of hmtx, glyf, head flags and the derivation of side bearings
Line breaking 2026-11-05
Line breaking selects where a paragraph is divided into successive lines. The choice combines the widths of words and spaces with a measure of acceptable layout. A glyph advance supplies part of the underlying geometry, while the chosen breaks determine which content shares a CSS line box in a web layout.
A greedy algorithm can put as much content as possible on each line before proceeding. Greedy line breaking is easy to compute, but an early choice can leave an awkward short line later. Line breaking with squared slack cost gives a small, explicit example. Suppose four word widths are , each internal space has width 1, and the permitted line width is 7, all in arbitrary consistent units. Greedy grouping produces line lengths . An alternative grouping produces . Charging squared unused width on every line except the last givesAn immediately fuller first line can therefore produce a worse paragraph under this particular cost.
Dynamic programming makes the global choice systematic. Let be the minimum cost for the first words, and let include words through and their internal spaces. For feasible lines, set , except that for the final line. ThenPossible break positions form a directed acyclic graph; a feasible line is an edge, so the same calculation finds a shortest path from the start to the end of the paragraph.
Donald E. Knuth and Michael F. Plass developed a richer paragraph-wide method using boxes, adjustable glue and penalties. Their Knuth-Plass line-breaking algorithm accommodates typographic choices beyond the fixed spaces and squared costs in the illustrative model above.[ref]
Breaking paragraphs into lines by Donald E. Knuth and Michael F. Plass. 1981 paper, summary and introduction; paragraph-wide optimization and dynamic programming
Pen position 2026-11-05
In glyph positioning, the pen position is the logical point from which the next glyph is placed. The word pen describes a layout convention: the renderer can draw an outline or a collection of pixels rather than trace a physical pen stroke. Simple horizontal layout places this reference point on the text baseline.[ref]
Glyph Metrics in the FreeType documentation. Section 1: the baseline and logical origin; section 3: advances
Let be the current pen position, a placement offset and the resolved glyph advance. The current glyph's drawing origin and the next logical point are, respectively,For example, in one horizontal coordinate system, , and draw at but leave the next logical point at . Moving the current shape and changing the progression of the run are separate operations.
A glyph's bounding box is therefore not a substitute for its pen position. A left side bearing can leave space between the logical origin and the ink, and a right side bearing records how the ink ends relative to the default advance. Kerning or attachment of a combining character can modify the placement or progression without changing the stored outline.
Pixels per em 2026-11-05
Pixels per em specifies the raster scale of one em. If font units make an em and the requested scale is pixels per em, a design length becomes pixels before grid fitting. The value measures the nominal typographic scale rather than the ink height of an individual glyph.[ref]
For output with a stated physical raster resolution of pixels per inch, a font size of digital typographic points givesThe factor 72 comes from the digital typographic point convention. For example, and give 24 pixels per em; a hypothetical glyph advance of 0.6 em then scales to 14.4 pixels. Doubling doubles the pixel count while preserving the requested physical length.
Horizontal and vertical pixel density can differ, in which case the two directions have distinct pixels per em. An application can also impose its own screen-to-physical-unit mapping. One must state which scale is being used rather than infer the physical size from a pixel count alone. Rasterization and grid fitting then determine how the scaled geometry becomes a visible image.
Point (typography) 2026-11-05
A typographic point is a unit used for font size, line height and other typographic distances. In the modern digital convention,Here the inch is 25.4 millimetres. The equation describes the digital convention; historical typographic point systems have not all used that same length. The modern
pt relation also appears among the absolute-length units defined for CSS.[ref]CSS Values and Units Module Level 3 by World Wide Web Consortium. Section5.2: absolute lengths and the pt, in and px equivalences
For example, a font size of 12 typographic points corresponds to a nominal em of one sixth of an inch, approximately 4.2333 millimetres. That sets the outline's scale, rather than the exact ink height of every glyph. A particular x-height or glyph advance can be a different fraction of an em.
The CSS conversion also gives 12 typographic points as 16 CSS pixels. A CSS pixel is a layout unit, so this equality does not promise 16 hardware pixels or a ruler-measured physical height on every screen. Zoom and the mapping to device pixels must be accounted for separately; the device pixel ratio records one part of that mapping.
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 , thenThus 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]
Horizontal Metrics Table by Microsoft. Deriving rsb from aw, lsb, xMin and xMax
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]
Glyph Metrics in the FreeType documentation. Section 1: baseline, pens and layouts
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]Baseline Tags by Microsoft. Registered baseline tags and their meanings in horizontal and vertical axes
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.
Text shaping 2026-11-05
Text shaping turns a sequence of Unicode text characters into a layout of glyphs from a chosen computer font. The result includes glyph indices, positions and glyph advances. A text character therefore does not determine a visible shape independently of its neighbors, writing system and selected computer font.[ref]
Shaping concepts in the HarfBuzz Manual. Text shaping: Unicode input, font-dependent two-dimensional glyph layout and shaping models
For example, the stored sequence
f followed by i can become a single typographic ligature. Contextual Arabic forms illustrate a different requirement: a letter's neighbors influence the selected glyph. Glyph substitution chooses forms, while glyph positioning places the chosen forms; kerning adjusts their spacing. These operations can preserve the original Unicode text, so copying text should not be implemented by reading glyph indices as if they were code points.[ref]Glyph Substitution Table by Microsoft. Overview: Arabic contextual forms, Latin ligatures and the character/glyph distinction
Text shaping precedes rasterization: first determine what shapes to draw and where; then determine the pixels that represent those shapes at the requested size.
Word separator 2026-11-05
A word separator is a text unit whose primary role is to separate words. Unicode SPACE U+0020 and non-breaking space U+00A0 are common examples. In CSS, the word-separator classification helps determine where word spacing is applied after white-space processing.[ref]
CSS Text Module Level 3 by World Wide Web Consortium. §7.1: word-separator characters and extra spacing
Separation and line breaking are related but distinct. In a suitable ordinary text context, a normal space between
10 and kg provides a possible break. Using a non-breaking space there keeps the number and unit together at that boundary. Both characters can still provide visible separation.[ref]Unicode Line Breaking Algorithm by the Unicode Consortium. Line-breaking properties: GL class and rules LB12/LB12a
A language can also write words without visible separators, so a count of space characters is not a universal word-counting method. Text shaping, word spacing and permitted breaks must follow the appropriate text-processing rules. A separator's stored character and the selected glyph advance jointly participate in the geometry.
Word spacing 2026-11-05
Word spacing is the separation between adjacent words in a line of text. Its nominal value comes from the computer font and layout settings; text justification can adjust it through typesetting glue. Letter spacing instead changes spacing within the text's sequence of letters. A script without visible word separators needs a different spacing strategy from an English sentence.[ref]
CSS Text Module Level 3 by World Wide Web Consortium. §§6.4 and 7.1–7.2: script-dependent justification and word/letter spacing
Suppose three typesetting boxes have widths 8, 6 and 10, and the two intervening spaces each have width 3. The natural line width isAdding 1 to each space gives width 32. Adding 1 to every glyph advance would generally produce a different layout, because there need not be one glyph per word or per stored character. Word spacing must therefore be applied to the intended separators rather than inferred from a count of glyphs.


