For each x element, determines the width and height of a bounding box that's big enough
to (just) enclose the provided text. Unit is pixel.
m_str_extents(
x,
fontname = "sans",
fontsize = 10,
bold = FALSE,
italic = FALSE,
fontfile = NULL
)# \donttest{
# The first run can be slow when font caches are missing
# as font files are then being scanned to build those font caches.
m_str_extents(letters, fontsize = 1:26)
#> [,1] [,2]
#> [1,] 0.561 0.555
#> [2,] 1.230 1.540
#> [3,] 1.440 1.668
#> [4,] 2.460 3.080
#> [5,] 2.820 2.780
#> [6,] 2.064 4.590
#> [7,] 4.305 5.502
#> [8,] 4.944 6.080
#> [9,] 2.322 6.633
#> [10,] 2.580 9.770
#> [11,] 5.874 8.360
#> [12,] 3.096 9.120
#> [13,] 12.155 7.098
#> [14,] 8.652 7.644
#> [15,] 9.075 8.340
#> [16,] 9.840 12.576
#> [17,] 10.455 13.362
#> [18,] 7.434 9.828
#> [19,] 9.101 10.564
#> [20,] 7.220 13.380
#> [21,] 12.978 11.466
#> [22,] 11.176 11.792
#> [23,] 18.078 12.328
#> [24,] 12.696 12.864
#> [25,] 12.750 19.400
#> [26,] 12.220 13.936
m_str_extents(letters[1:3],
bold = c(TRUE, FALSE, TRUE),
italic = c(FALSE, TRUE, TRUE),
fontname = c("sans", "sans", "sans") )
#> [,1] [,2]
#> [1,] 6.04 5.67
#> [2,] 5.79 7.70
#> [3,] 4.83 5.66
# }