Skip to content

class Font

All TeX fonts are represented to Lua code as tables, and internally as C code structures. All keys in the table below are saved in the internal font structure if they are present in the table returned by the define_font callback, or if they result from the normal tfm/vf reading routines if there is no define_font callback defined.

😱 Types incomplete or incorrect? 🙏 Please contribute!


fields


Font.name


Font.name : string

metric (file) name

Font.area


Font.area : string

(directory) location, typically empty

Font.used


Font.used : boolean

Indicates usage (initial: false). The key used is set by the engine when a font is actively in use. This makes sure that the font's definition is written to the output file (DVI or PDF). The tfm reader sets it to false.

Font.characters


Font.characters : table<integer,FontCharacter>

the defined glyphs of this font

Font.checksum


Font.checksum : integer

default: 0

Font.designsize


Font.designsize : integer

expected size (default: 655360 == 10pt)

Font.direction


Font.direction : FontDirection

default: 0

Font.encodingbytes


Font.encodingbytes : integer

default: depends on format

Font.encodingname


Font.encodingname : string

encoding name

Font.fonts


Font.fonts : table

locally used fonts

Font.psname


Font.psname : string

This is the PostScript fontname in the incoming font source, and it's used as fontname identifier in the PDF output. This has to be a valid string, e.g.\ no spaces and such, as the backend will not do a cleanup. This gives complete control to the loader.

Font.fullname


Font.fullname : string

output font name, used as a fallback in the PDF output if the psname is not set

Font.subfont


Font.subfont : number

default: 0, index in (ttc) font with multiple fonts. The subfont parameter can be used to specify the subfont in a ttc font. When given, it is used instead of the psname and fullname combination. The first subfont has number 1. A zero value signals using the names as lookup.

Font.header


Font.header : string

header comments, if any

Font.hyphenchar


Font.hyphenchar : integer

default: TeX's hyphenchar

Font.parameters


Font.parameters : FontParameters

default: 7 parameters, all zero

Font.size


Font.size : integer

the required scaling (by default the same as designsize)

Font.skewchar


Font.skewchar : integer

default: TeX's skewchar

Font.type


Font.type : FontType

basic type of this font

Font.format


Font.format : FontFormat

disk format type

Font.embedding


Font.embedding : FontEmbedding

PDF inclusion

Font.filename


Font.filename : string

the name of the font on disk

Font.tounicode


Font.tounicode : integer

When this is set to 1 LuaTeX assumes per-glyph tounicode entries are present in the font.

Font.stretch


Font.stretch : integer

the “stretch” value from expandglyphsinfont

Font.shrink


Font.shrink : integer

the “shrink” value from expandglyphsinfont

Font.step


Font.step : integer

the “step” value from expandglyphsinfont

Font.expansion_factor


Font.expansion_factor : integer

the actual expansion factor of an expanded font

Font.attributes


Font.attributes : string

the pdffontattr. The key attributes can be used to set font attributes in the PDF file.

Font.cache


Font.cache : string

This key controls caching of the Lua table on the TeX end where yes means: use a reference to the table that is passed to LuaTeX (this is the default), and no means: don't store the table reference, don't cache any Lua data for this font while renew means: don't store the table reference, but save a reference to the table that is created at the first access to one of its fields in the font.

Font.nomath


Font.nomath : boolean

This key allows a minor speedup for text fonts. If it is present and true, then LuaTeX will not check the character entries for math-specific keys.

Font.oldmath


Font.oldmath : boolean

This key flags a font as representing an old school TeX math font and disables the OpenType code path.

Font.slant


Font.slant : integer

This parameter will tilt the font and does the same as SlantFont in the map file for Type1 fonts.

Font.extend


Font.extend : integer

This parameter will scale the font horizontally and does the same as ExtendFont in the map file for Type1 fonts.

Font.squeeze


Font.squeeze : integer

This parameter will scale the font vertically and has no equivalent in the map file.

Font.width


Font.width : integer

The backend will inject PDF operators that set the penwidth. The value is (as usual in TeX) divided by 1000. It works with the mode file.

Font.mode


Font.mode : integer

The backend will inject PDF operators that relate to the drawing mode with 0 being a fill, 1 being an outline, 2 both draw and fill and 3 no painting at all.