Skip to contents

Calculate lines per inch and characters per inch for font

Usage

font_lcpi(font_family = "Courier", font_size = 12, lineheight = 1)

Arguments

font_family

character(1). 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.

Value

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

Details

This function creates opens pdf graphics device writing to an 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

font_lcpi()
#> $cpi
#> [1] 10
#> 
#> $lpi
#> [1] 6
#> 

font_lcpi(font_size = 8)
#> $cpi
#> [1] 15
#> 
#> $lpi
#> [1] 9
#> 

font_lcpi(font_size = 8, lineheight = 1.1)
#> $cpi
#> [1] 15
#> 
#> $lpi
#> [1] 8.181818
#>