Advance Width vs Sidebearing in FontForge
In FontForge, understanding the distinction between advance width and sidebearings is fundamental to mastering font spacing and horizontal metrics. Advance width refers to the total horizontal distance the text cursor moves forward when a character is typed, while sidebearings represent the empty margins placed to the left and right of the glyph's visible outline. Together, these two metrics determine how characters sit beside one another, preventing text from appearing crowded or disconnected.
What Is Advance Width?
The advance width is the total allocated horizontal footprint of a glyph. It encompasses not only the visible shape (the glyph outline or bounding box) but also the whitespace surrounding it.
When a text-rendering engine places characters in a line, it uses the advance width to determine the insertion point for the next consecutive character. In FontForge, the advance width is demarcated by a vertical line to the right of the glyph canvas. If you alter the advance width without changing the position of the glyph, you directly affect how closely following characters will appear.
What Are Sidebearings?
Sidebearings are the margins of whitespace flanking the visible contours of a glyph. There are two distinct sidebearings for horizontal text:
- Left Sidebearing (LSB): The distance between the glyph origin (the zero coordinate line on the horizontal axis) and the leftmost point of the glyph's visual outline.
- Right Sidebearing (RSB): The distance between the rightmost point of the glyph's visual outline and the advance width marker line.
Sidebearings prevent visual collisions between adjacent letters. In FontForge, sidebearings can be positive, zero, or negative:
- Positive sidebearing: Leaves empty space between the character outline and the boundary.
- Zero sidebearing: The character outline touches the origin or advance line.
- Negative sidebearing: The character outline extends past the origin or advance line, allowing visual overlap (common in italics, swashes, or certain accents).
The Mathematical Relationship
Advance width and sidebearings are mathematically dependent on one another and the glyph's physical outline:
\[\text{Advance Width} = \text{Left Sidebearing} + \text{Glyph Width (Bounding Box)} + \text{Right Sidebearing}\]
Because of this relationship, modifying one value often recalculates another in FontForge:
- Changing the LSB typically shifts the glyph outline relative to the origin, which will alter the RSB unless the advance width is also adjusted.
- Changing the RSB directly alters the advance width while keeping the glyph outline and LSB unchanged.
- Changing the advance width directly expands or contracts the RSB, provided the glyph outline remains fixed.
Managing Them in FontForge
In FontForge, these values can be adjusted in two primary environments:
- The Glyph Window: By opening an individual glyph, you can manually drag the vertical advance width line or use the transform tools to shift the glyph outline to modify the LSB.
- The Metrics Window (Window > Open Metrics Window): This window allows you to preview multiple characters side-by-side. You can click and drag the boundary lines representing the LSB and advance width or type exact numerical values into the metric cells at the bottom of the window for precise adjustments.