get_embedded_font returns which font is actually embedded by cairo_pdf. cleave converts a delimiter separated string into a vector. inch(x) is equivalent to unit(x, "in"). is_color_invisible tells whether the color is transparent (and hence need not be drawn).

is_color_invisible(col)

get_embedded_font(font, char)

inch(inches)

cleave(s, sep = ",", float = FALSE, color = FALSE)

file2grob(file, distort = TRUE)

Arguments

col

Color

font

A character vector of font(s) passed to the fontfamily argument of grid::gpar.

char

A character vector of character(s) to be embedded by grid::grid.text

inches

Number representing number of inches

s

String to convert

sep

Delimiter (defaults to ",")

float

If `TRUE` cast to numeric

color

if `TRUE` convert empty strings to `"transparent"`

file

Filename of image

distort

Logical value of whether one should preserve the aspect ratio or distort to fit the area it is drawn in

Value

get_embedded_font returns character vector of fonts that were actually embedded by cairo_pdf. NA's means no embedded font detected: this either means that no font was found or that a color emoji font was found and instead of a font an image was embedded.

Details

get_embedded_font depends on pdffonts being on the system path (on many OSes found in a poppler-utils package).

Examples

to_x(90, 1)
#> [1] 6.123234e-17
to_y(180, 0.5)
#> [1] 6.123234e-17
to_t(0, -1)
#> [1] -90
to_r(0.5, 0)
#> [1] 0.5
cleave("0.5,0.2,0.4,0.5", float=TRUE)
#> [1] 0.5 0.2 0.4 0.5
cleave("black,darkred,#050EAA,,", color=TRUE)
#> [1] "black" "darkred" "#050EAA" "transparent" "transparent"
if (require("grid")) { grid.rect(width=inch(1), height=inch(3), gp=gpar(fill="blue")) }
if ((Sys.which("pdffonts") != "") && capabilities("cairo")) { chars <- c("a", "\u2666") fonts <- c("sans", "Sans Noto", "Noto Sans", "Noto Sans Symbols2") get_embedded_font(fonts, chars) }
#> char requested_font embedded_font #> 1 a sans NimbusSans-Regular #> 2 ♦ sans NimbusSans-Regular #> 3 a Sans Noto DejaVuSans #> 4 ♦ Sans Noto DejaVuSans #> 5 a Noto Sans NotoSans-Regular #> 6 ♦ Noto Sans DejaVuSans #> 7 a Noto Sans Symbols2 DejaVuSans #> 8 ♦ Noto Sans Symbols2 NotoSansSymbols2-Regular
is_color_invisible("transparent")
#> [1] TRUE
is_color_invisible(NA)
#> [1] TRUE
is_color_invisible("blue")
#> [1] FALSE
is_color_invisible("#05AE9C")
#> [1] FALSE