font_utils: Font utility functions

Description Usage Arguments Details Value Examples

Description

get_embedded_font() returns which font is actually embedded by cairo_pdf() for a given character. has_font() tries to determine if a given font is available on the OS.

Usage

1
2
3
get_embedded_font(font, char)

has_font(font)

Arguments

font

A character vector of font(s).

char

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

Details

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

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.

Examples

1
2
3
4
5
6
7
 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)

     has_font("Dejavu Sans")
 }

trevorld/piecepack documentation built on July 22, 2021, 3:26 a.m.