Learn R Programming

formatters (version 0.5.11)

font_lcpi: Calculate lines per inch and characters per inch for font

Description

Calculate lines per inch and characters per inch for font

Usage

font_lcpi(
  font_family = "Courier",
  font_size = 8,
  lineheight = 1,
  fontspec = font_spec(font_family, font_size, lineheight)
)

Value

A named list with cpi and lpi, the characters and lines per inch, respectively.

Arguments

font_family

(string)
name of a font family. An error will be thrown if the family named is not monospaced. Defaults to "Courier".

font_size

(numeric(1))
font size. Defaults to 12.

lineheight

(numeric(1))
line height. Defaults to 1.

fontspec

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

Details

This function opens a PDF graphics device, writes to a temporary file, then utilizes grid::convertWidth() and grid::convertHeight() to calculate lines per inch and characters per inch for the specified font family, size, and line height.

An error is thrown if the font is not monospaced (determined by comparing the effective widths of the M and . glyphs).

Examples

Run this code
font_lcpi <- getFromNamespace("font_lcpi", "formatters")

font_lcpi()
font_lcpi(font_size = 8)
font_lcpi(font_size = 8, lineheight = 1.1)

Run the code above in your browser using DataLab