Typography — since 1.8.0
Every typographic option in pdfnative is opt-in under layout.typography, so a document built without them is byte-identical to earlier releases. Pick a preset, generate it with the option and without, and open the two PDFs side by side: the difference is the feature.
View underlying code
Diagnostics (layout.onDiagnostic)
Generate a PDF to see the diagnostics its build raised. Every preset wires layout.onDiagnostic; most builds raise none.
What the options do:
- Page breaking —
splitParagraphsbreaks at line boundaries;widows/orphanskeep single lines from being stranded;keepHeadingsWithNextkeeps a heading with its content —truereserves two lines of the following paragraph,{ minLines: 3 }a house-style three (1.8.0). - Short words —
bindShortWordsconverts the space after a one-letter word into a no-break space, so no line ends on "a" or "I" (1.8.0; a house style, and orthography in Polish, Czech or Russian). - Justification —
align: 'justify'fills the measure word by word;opticalMarginshangs punctuation past the edge. - Spacing —
unitBindingkeeps 150 € together (ISO 80000-1);punctuationSpacing: 'fr'sets French no-break spaces. - Hyphenation — the library ships no dictionary;
setHyphenationProvider()installs a function that returns break positions per word and receivestypography.hyphenationLanguage; soft hyphens (U+00AD) the author wrote need no provider (1.8.0). - Metrics —
metrics: 'exact'measures base-14 text with the Adobe Core 14 AFM advances instead of the historical estimate, which buckets every dash, ellipsis, quote and accented letter at 556 units (1.8.0). Opt-in because better measurement moves line breaks. - Kerning and features —
kerningapplies the font's pair adjustments;fontFeaturesselects OpenType single substitutions such asonum,pnumandsmcp. Both need a registered font. A tag the font does not declare, or one that substitutes nothing (tnumon Noto Sans), raises theTYPOGRAPHY_FEATURE_INEFFECTIVEdiagnostic (1.8.0).
See the Typography guide for every option.