m_str_extents: Compute string extents for a vector of string.

Description Usage Arguments Examples

View source: R/m_str_extents.R

Description

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.

Usage

1
2
m_str_extents(x, fontname = "sans", fontsize = 10, bold = FALSE,
  italic = FALSE, fontfile = NULL)

Arguments

x

Character vector of strings to measure

fontname

Font name. A vector of character to match with x.

fontsize

Font size. A vector of numeric to match with x.

bold, italic

Is text bold/italic?. A vector of logical to match with x.

fontfile

Font file. A vector of character to match with x.

Examples

1
2
3
4
5
6
7
# 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)
m_str_extents(letters[1:3],
  bold = c(TRUE, FALSE, TRUE),
  italic = c(FALSE, TRUE, TRUE),
  fontname = c("sans", "sans", "sans") )

gdtools documentation built on April 3, 2020, 5:19 p.m.