1. Baseline, pens and layouts
The baseline is an imaginary line that is used to "guide" glyphs when rendering text. It can be horizontal (e.g. Roman, Cyrillic, Arabic, etc.) or vertical (e.g. Chinese, Japanese, Korean, etc). Moreover, to render text, a virtual point, located on the baseline, called the pen position or origin, is used to locate glyphs.
Each layout uses a different convention for glyph placement:
2. Typographic metrics and bounding boxes
A various number of face metrics are defined for all glyphs in a given font.
Other, simpler metrics are:
3. Bearings and AdvancesEach glyph has also distances called bearings and advances. Their definition is constant, but their values depend on the layout, as the same glyph can be used to render text either horizontally or vertically:
Here is a picture giving all the details for horizontal metrics:
And here is another one for the vertical metrics:
4. The effects of grid-fitting
Because hinting aligns the glyph's control points to the pixel grid, this process slightly modifies the dimensions of character images in ways that differ from simple scaling.
For example, the image of the lowercase "m" letter sometimes fits a square in the master grid. However, to make it readable at small pixel sizes, hinting tends to enlarge its scaled outline in order to keep its three legs distinctly visible, resulting in a larger character bitmap.
The glyph metrics are also influenced by the grid-fitting process:
This has some implications:
Performing 2D transformations on glyph outlines is very easy with FreeType. However, when using translation on a hinted outlines, one should aways take care of exclusively using integer pixel distances (which means that the parameters to the FT_Outline_Translate() API should all be multiples of 64, as the point coordinates are in 26.6 fixed float format).
Otherwise, the translation will simply ruin the hinter's work, resulting in a very low quality bitmaps!
5. Text widths and bounding box
As seen before, the "origin" of a given glyph corresponds to the position of the pen on the baseline. It is not necessarily located on one of the glyph's bounding box corners, unlike many typical bitmapped font formats. In some cases, the origin can be out of the bounding box, in others, it can be within it, depending on the shape of the given glyph.
Likewise, the glyph's "advance width" is the increment to apply to the pen position during layout, and is not related to the glyph's "width", which really is the glyph's bounding width.
The same conventions apply to strings of text. This means that: