Skip to contents

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

Usage

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,]  7.353516  6.890625
#>  [2,]  7.617188  9.287109
#>  [3,]  6.597656  6.890625
#>  [4,]  7.617188  9.287109
#>  [5,]  7.382812  6.890625
#>  [6,]  4.224609  9.117188
#>  [7,]  7.617188  9.216797
#>  [8,]  7.605469  9.117188
#>  [9,]  3.333984  9.117188
#> [10,]  3.333984 11.613281
#> [11,]  6.949219  9.117188
#> [12,]  3.333984  9.117188
#> [13,] 11.689453  6.720703
#> [14,]  7.605469  6.720703
#> [15,]  7.341797  6.890625
#> [16,]  7.617188  9.216797
#> [17,]  7.617188  9.216797
#> [18,]  4.933594  6.720703
#> [19,]  6.251953  6.890625
#> [20,]  4.705078  8.425781
#> [21,]  7.605469  6.890625
#> [22,]  7.101562  6.562500
#> [23,]  9.814453  6.562500
#> [24,]  7.101562  6.562500
#> [25,]  7.101562  9.058594
#> [26,]  6.298828  6.562500
str_extents("Hello World!", bold = TRUE, italic = FALSE,
  fontname = "sans", fontsize = 12)
#>         [,1]     [,2]
#> [1,] 84.4043 9.287109