open_font_dev: Activate font state

View source: R/tostring.R

open_font_devR Documentation

Activate font state

Description

Activate font state

Usage

open_font_dev(fontspec, silent = FALSE)

close_font_dev()

debug_font_dev()

undebug_font_dev()

Arguments

fontspec

(font_spec)
a font_spec object specifying the font information to use for calculating string widths and heights, as returned by font_spec().

silent

(logical(1))
If FALSE, the default, a warning will be emitted if this function switches away from an active graphics device.

Details

The font device state is an environment with four variables guaranteed to be set:

open

(logical(1))
whether a device is already open with font info

fontspec

(font_spec)
the font specification, if any, that is currently active (list() if none is).

spacewidth

(numeric(1))
the width of the space character in the currently active font.

ismonospace

(logical(1))
whether the specified font is monospaced.

open_font_dev opens a pdf device with the specified font only if there is not one currently open with the same font. If a new device is opened, it caches spacewidth and ismonospace for use in nchar_ttype).

close_font_dev closes any open font state device and clears the cached values.

debug_font_dev and undebug_font_dev activate and deactivate, respectively, logging of where in the call stack font devices are being opened.

Value

  • open_font_dev returns a logical value indicating whether a new pdf device was opened.

  • close_font_dev, debug_font_dev and undebug_font_dev return NULL.

In all cases the value is returned invisibly.

Examples

open_font_dev(font_spec("Times"))
nchar_ttype("Hiya there", font_spec("Times"))
close_font_dev()


formatters documentation built on June 22, 2024, 9:42 a.m.