Calculates font metrics for a specified font, font size, and style. The function renders specific characters to measure ascender and descender heights, which are used for text alignment and positioning in graphical outputs.
get_font_metrics(font, font_size, style = "plain")
A list containing:
Numeric value of the height adjustment needed for ascenders.
Numeric value of the height adjustment needed for descenders.
Numeric value of the height of a neutral character.
The function renders specific characters ("d"
for ascender, "g"
for descender, "x"
for neutral) using the specified font parameters. It calculates the bounding box of each character to determine the necessary adjustments for accurate text positioning.
# Get height of basic sans font
get_font_metrics("sans", 60)
#> $ascender_adjustment
#> [1] 14
#>
#> $descender_adjustment
#> [1] 14
#>
#> $neutral_height
#> [1] 31
#>
#> $total_height
#> [1] 56
#>