Sub topic 1
How letters are spaced by default: advance widths and sidebearings
Prerequisites
This chapter assumes you know these terms: typeface, font, glyph, baseline, and point size. It also assumes you have used a design tool such as Figma, Illustrator, or InDesign, or have written basic CSS. The code example is JavaScript and runs in Node.js or a browser console.
The default spacing is built into each glyph
A font does not store the gaps between letters as separate objects. Each glyph carries its own spacing, and the gap you see between two letters comes from the glyphs sitting side by side.
Each glyph has three horizontal measurements:
- Advance width is the distance the text cursor moves after the glyph is placed. It is the total horizontal space the glyph occupies.
- Left sidebearing (LSB) is the empty space between the start of the advance and the left edge of the visible outline.
- Right sidebearing (RSB) is the empty space between the right edge of the outline and the end of the advance.
The three measurements are linked:
advance width = left sidebearing + outline width + right sidebearingThe type designer sets these values when drawing the font. A round letter such as "o" usually gets small sidebearings. A letter with a flat vertical stem, such as "n" or "l", gets slightly larger ones so the stems do not crowd each other.
Units
Font files measure these values in font units. The font declares a grid called units per em. Many fonts use 1000, and TrueType fonts often use 2048. A value of 70 in a 1000-unit font means 70/1000 of an em. An em is the current font size, so at 20 px the value is 1.4 px.
Worked example
This script uses made-up but realistic numbers for a 1000-unit font. It checks the advance width formula and computes the gap between two glyphs.
const unitsPerEm = 1000;
const glyphs = {
n: { advance: 556, lsb: 70, outline: 416, rsb: 70 },
o: { advance: 550, lsb: 40, outline: 470, rsb: 40 },
};
for (const [name, g] of Object.entries(glyphs)) {
const sum = g.lsb + g.outline + g.rsb;
console.log(name, "advance matches:", sum === g.advance);
}
// Visible gap between "n" followed by "o"
const gap = glyphs.n.rsb + glyphs.o.lsb;
console.log("gap in units:", gap); // 110
const fontSizePx = 20;
console.log("gap in px:", (gap / unitsPerEm) * fontSizePx); // 2.2The gap between two neighbors is the first glyph's right sidebearing plus the second glyph's left sidebearing. Here that is 70 + 40 = 110 units, or 2.2 px at 20 px.
Why default spacing is not always enough
Sidebearings are fixed per glyph. The "n" always has an RSB of 70, whatever letter follows it. That works for most pairs. It fails for pairs whose shapes interlock or leave a large open area, such as "AV" or "To". The diagonal edges leave a wide hole even though each glyph's sidebearings are reasonable.
Fonts handle this with extra data about specific pairs. That data is called kerning, and a later chapter covers it. The key point here is the order of operations. The browser or design tool places glyphs using advance widths first. It then applies pair adjustments and any tracking you request.
Common mistakes at this stage
- Treating the advance width as the visible width of a letter. The advance includes the empty sidebearings.
- Assuming the gap between letters is a single number. It is the sum of two sidebearings and varies by pair.
- Editing the space in the document to fix a flaw that belongs in the font's sidebearings. A badly spaced font needs repair at the font level, not per-paragraph fixes.
Exercise
A font uses 1000 units per em. Glyph "l" has an LSB of 80 and an RSB of 80. Glyph "i" has an LSB of 75 and an RSB of 75. What is the default gap in px between "l" followed by "i" at 16 px, before any kerning or tracking?
Show answer
The gap is the RSB of "l" plus the LSB of "i": 80 + 75 = 155 units. At 16 px, 155/1000 × 16 = 2.48 px.