outline_convert.encode

outline_convert

encode(desc) -> bytes, stats

Write an outline table

desc fielddescription
metricsem, ascender, descender, advance, x_height, cap_height, underline_pos, underline_thickness, strike_pos, strike_thickness, in font units
faces1 to 4 maps of codepoint to glyph, in the order regular, bold, italic, bold italic
rulesa list of lookups a face, each a list of rules; none when left out
noticethe text the table carries, empty when left out

A glyph is { cells = 1 or 2, contours = { { { x, y, on }, ... }, ... } } with integer points in font units; tag names its source for the stats. Glyphs with the same record share one glyph in the table, unless a gid tells them apart. A codepoint whose record is the same in every face goes to the pool.

A rule is { input, behind, ahead, map } over glyphs. input is a list of glyphs, and behind and ahead are lists of such lists, behind nearest first. map is a list of { from, to } pairs, or nil for a rule that substitutes nothing. A glyph a rule names that no codepoint holds is stored after the others.

The stats count glyphs, codepoints and pooled codepoints, the glyph_bytes, range_bytes and index_bytes, and under tags the glyphs and bytes a tag. They count the lookups, the rules and their rule_bytes, and the extra_glyphs only rules name with their extra_glyph_bytes.

Nil and an error for a point or a metric that does not fit 16 bits, a glyph of other than 1 or 2 cells, a count of faces out of range, or a rule that maps one glyph to two.