This function is a simple wrapper around systemfonts::string_metrics_dev().
It determines widths, ascent and descent in inches.
This function will replace the following functions defined in this file:
str_extents(), str_metrics() and m_str_extents().
strings_sizes(
x,
fontname = "sans",
fontsize = 10,
bold = FALSE,
italic = FALSE
)A character vector of strings to measure. All arguments are vectorized
and recycled to match the length of x.
A character vector specifying the font family name (e.g., "sans", "serif", "mono"). Default is "sans". This argument is vectorized.
A numeric vector specifying the font size in points. Default is 10. This argument is vectorized.
A logical vector indicating whether the text should be bold. Default is FALSE. This argument is vectorized.
A logical vector indicating whether the text should be italic. Default is FALSE. This argument is vectorized.
strings_sizes(letters)
#> # A tibble: 26 × 3
#> width ascent descent
#> <dbl> <dbl> <dbl>
#> 1 0.0779 0.0833 0
#> 2 0.0855 0.111 0
#> 3 0.0666 0.0833 0
#> 4 0.0855 0.111 0
#> 5 0.0783 0.0833 0
#> 6 0.0477 0.111 0
#> 7 0.0855 0.0833 0.0417
#> 8 0.0859 0.111 0
#> 9 0.0358 0.111 0
#> 10 0.0358 0.111 0.0417
#> # ℹ 16 more rows
strings_sizes("Hello World!", bold = TRUE, italic = FALSE,
fontname = "sans", fontsize = 12)
#> # A tibble: 1 × 3
#> width ascent descent
#> <dbl> <dbl> <dbl>
#> 1 1.01 0.139 0.0139