Reference

Fonts in a generated document, past the CSS property

The properties are covered in the paged-CSS reference: @font-face and where the src has to point, font-display, unicode-range and font-variant-numeric. These pages are the decisions around them.

Which file to serve and whether you are licensed to embed it at all. What the engine invents when you ask for a weight the family does not have. Why two fonts at the same size produce different line counts. And what happens when a machine reads the finished document back, which is where ligatures and icon fonts turn a page that looks perfect into text that is not what you set.

On this API: there is no font option of any kind. A font arrives the way every other subresource arrives, fetched from the URL your @font-face names, and what was used is embedded in the output. No upload, no font list, no substitution control, no subsetting switch. For scripts other than Latin, see writing systems, which covers shaping rather than supply.

Getting the font into the document

Before anything renders, a font file has to be reachable, in a format the engine reads, and legally embeddable. Two of those three are technical and the third is the one that stops a project.

  • Font file formats

    WOFF2, WOFF, TTF and OTF all work, and the one you serve changes the download size, not what ends up in the finished document.

  • Font licensing and embedding

    Embedding a font into a document distributes that font, and whether you are permitted to do that is a question about the licence rather than about the technology.

  • Font fallback chain

    The list of families after the one you want, which decides what the document looks like on the day the font does not load.

What the engine does with it

Given a font, the engine makes decisions you did not ask it to make: which weight to use when the one you named is missing, how tall to make the line box, which optional glyph substitutions to apply. Each of those has a default and none of the defaults are obviously right.

  • Synthesised bold and italic

    What the engine does when you ask for a weight or a style the family does not have: it makes one up, and the result is worse than the real thing in ways that are easy to miss.

  • Variable fonts

    One file carrying a continuous range of weights instead of several files carrying fixed ones, which solves a download problem a generated document does not have.

  • Font metrics and the line box

    The ascent, descent and line gap recorded inside the font file, which decide how tall a line is before your stylesheet says anything.

What happens to the text afterwards

A document is read by people and by machines. These are the pages about the second one: what happens when the text in the finished file is selected, copied, searched or extracted, and why it is sometimes not the text you set.

  • OpenType features

    Optional glyph substitutions built into a font, which are the difference between real small capitals and shrunken capitals, and which are off unless asked for.

  • Ligatures and text extraction

    A ligature is one glyph standing for two or more characters, and unless the font tells the reader which characters those were, the text comes back out wrong.

  • Icon fonts

    Icons delivered as font glyphs, which look fine on the page and turn the document's extracted text into rubbish.

Two topics that are not here

Subsetting, and monospace alignment in figures. Both were drafted and both turned out to be pages that already exist: unicode-range covers the subsetting mechanism and the trade it makes, and font-variant-numeric covers tabular figures, which the document-section pages then use a dozen times. A second page on either would have been the same material with a different title.