Home  ›  Playgrounds  ›  Typography (v1.8.0)

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 breakingsplitParagraphs breaks at line boundaries; widows / orphans keep single lines from being stranded; keepHeadingsWithNext keeps a heading with its content — true reserves two lines of the following paragraph, { minLines: 3 } a house-style three (1.8.0).
  • Short wordsbindShortWords converts 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).
  • Justificationalign: 'justify' fills the measure word by word; opticalMargins hangs punctuation past the edge.
  • SpacingunitBinding keeps 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 receives typography.hyphenationLanguage; soft hyphens (U+00AD) the author wrote need no provider (1.8.0).
  • Metricsmetrics: '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 featureskerning applies the font's pair adjustments; fontFeatures selects OpenType single substitutions such as onum, pnum and smcp. Both need a registered font. A tag the font does not declare, or one that substitutes nothing (tnum on Noto Sans), raises the TYPOGRAPHY_FEATURE_INEFFECTIVE diagnostic (1.8.0).

See the Typography guide for every option.