Determines the width and height of a bounding box that's big enough to (just) enclose the provided text.

str_extents(
  x,
  fontname = "sans",
  fontsize = 12,
  bold = FALSE,
  italic = FALSE,
  fontfile = ""
)

Arguments

x

Character vector of strings to measure

fontname

Font name

fontsize

Font size

bold, italic

Is text bold/italic?

fontfile

Font file

Examples

str_extents(letters)
#>         [,1]   [,2]
#>  [1,]  6.732  6.660
#>  [2,]  7.380  9.240
#>  [3,]  5.760  6.672
#>  [4,]  7.380  9.240
#>  [5,]  6.768  6.672
#>  [6,]  4.128  9.180
#>  [7,]  7.380  9.432
#>  [8,]  7.416  9.120
#>  [9,]  3.096  8.844
#> [10,]  3.096 11.724
#> [11,]  6.408  9.120
#> [12,]  3.096  9.120
#> [13,] 11.220  6.552
#> [14,]  7.416  6.552
#> [15,]  7.260  6.672
#> [16,]  7.380  9.432
#> [17,]  7.380  9.432
#> [18,]  4.956  6.552
#> [19,]  5.748  6.672
#> [20,]  4.332  8.028
#> [21,]  7.416  6.552
#> [22,]  6.096  6.432
#> [23,]  9.432  6.432
#> [24,]  6.348  6.432
#> [25,]  6.120  9.312
#> [26,]  5.640  6.432
str_extents("Hello World!", bold = TRUE, italic = FALSE,
  fontname = "sans", fontsize = 12)
#>        [,1]  [,2]
#> [1,] 73.308 9.276