Vertical metrics of the lines of text written with a font, read from the
font file: the part of a line above its baseline (ascent), the part
below (descent) and their sum, the distance between the baselines of two
lines in single spacing (line_height). Multiply line_height by a line
spacing factor (1.5 for example) to get the distance between baselines with
this spacing.
The values follow the rule of the text metrics of Windows, applied by
'Microsoft Word' for single line spacing: ascent is the usWinAscent of
the 'OS/2' table plus the external leading, descent is its
usWinDescent; the external leading is the line gap of the 'hhea' table,
reduced by what usWinAscent and usWinDescent add to the ascender and
descender of 'hhea', and not negative. Fonts without these values use the
ascender, descender and line gap of 'hhea'.
These metrics depend on the font only, unlike the ascent and descent
returned by strings_sizes(), which are those of the ink of the glyphs
of a string. Fonts are found as with strings_sizes().
See also
Other functions for font metrics:
m_str_extents(),
str_metrics(),
strings_sizes()
Examples
font_line_metrics(c("sans", "serif"), fontsize = 12)
#> ascent descent line_height
#> 1 0.1547038 0.03930664 0.1940104
#> 2 0.1547038 0.03930664 0.1940104
# distance between baselines with a line spacing of 1.5, in points
font_line_metrics("sans", fontsize = 12)$line_height * 1.5 * 72
#> [1] 20.95312