Skip to contents

This function typesets bits of text to estimate the width of a textblock that averages wrap characters wide. This is useful for back-calculating page dimensions to suit the optimal line length of 66 characters (or whatever your project calls for).

Usage

estimate_line_length(font, fontsize = c("10pt", "11pt", "12pt"), wrap = 66)

Arguments

font

name of font, passed to \setmainfont{}

fontsize

fontsize, passed to \documentclass options

wrap

desired number of characters per line, passed to sample_text().

Value

Returns a named list with average ("mean") and standard deviation ("sd") of desired text width

Details

This rather brutish function uses LuaLaTeX with fontspec and pdftools for R, and it assumes that your TeX installation is configured to access fonts by name. It makes no attempt to check your system for required resources, handle errors, or protect against injection of malicious code.