string_width | R Documentation |
This is a very simple alternative to shape_string()
that simply calculates
the width of strings without taking any newline into account. As such it is
suitable to calculate the width of words or lines that has already been
splitted by \n
. Input is recycled to the length of strings
.
string_width(
strings,
family = "",
italic = FALSE,
bold = FALSE,
size = 12,
res = 72,
include_bearing = TRUE,
path = NULL,
index = 0
)
strings |
A character vector of strings |
family |
The name of the font families to match |
italic |
logical indicating the font slant |
bold |
logical indicating whether the font weight |
size |
The pointsize of the font to use for size related measures |
res |
The ppi of the size related mesures |
include_bearing |
Logical, should left and right bearing be included in the string width? |
path , index |
path an index of a font file to circumvent lookup based on family and style |
A numeric vector giving the width of the strings in pixels. Use the
provided res
value to convert it into absolute values.
strings <- c('A short string', 'A very very looong string')
string_width(strings)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.