Fonts
Built-in fonts
Section titled “Built-in fonts”Papyra embeds the Liberation family - Liberation Sans, Liberation Serif, and Liberation Mono, each in regular, bold, italic, and bold-italic. They are metric-compatible with Arial, Times New Roman, and Courier New, and they ship inside the library, so a document with no font configuration renders identically everywhere.
doc.DefaultTextStyle(TextStyle.Default.WithFontFamily("Liberation Serif"));How a family reaches each format
Section titled “How a family reaches each format”Layout always measures with the built-in faces, whatever you render to. Only PDF can embed them, so the other three have to name a font the reader already has - and that name is chosen to be the metric-compatible twin of the face that was measured. Same advance widths, same line breaks, same table columns.
| Measured face | DOCX and XLSX | HTML | |
|---|---|---|---|
| Liberation Sans | embedded | Arial |
Arial, Helvetica, "Liberation Sans", sans-serif |
| Liberation Serif | embedded | Times New Roman |
"Times New Roman", "Liberation Serif", serif |
| Liberation Mono | embedded | Courier New |
"Courier New", "Liberation Mono", monospace |
The default is 10pt Liberation Sans in all four formats. A family Papyra does not know - Verdana, say - is measured with Liberation Sans and passed through under its own name, so the reader sees real Verdana while the geometry was computed for the substitute. Register the font (below) if the two must agree, or pick one of the names above.
Registering custom fonts
Section titled “Registering custom fonts”Register any TrueType font at the document level, then reference it by the name you chose:
var document = Document.Create(doc => doc .RegisterFont("Brand Sans", regular: File.ReadAllBytes("BrandSans-Regular.ttf"), bold: File.ReadAllBytes("BrandSans-Bold.ttf")) .Paragraph(p => p.Text("Styled with a custom font", TextStyle.Default.WithFontFamily("Brand Sans"))));italic and boldItalic variants are optional; missing variants fall back to regular.
Unicode and embedding (PDF)
Section titled “Unicode and embedding (PDF)”The PDF renderer embeds fonts as Type0/CIDFontType2, which means full Unicode - any script the font covers works, including combining marks and non-Latin scripts. Only the font variants a document actually uses are embedded, and each embedded font is subsetted to the glyphs that appear in the document, keeping file sizes small.
What DOCX and XLSX do
Section titled “What DOCX and XLSX do”See also
Section titled “See also”- Styling and colors - where
FontFamilyfits into style inheritance - PDF/A output - font embedding is required for PDF/A, and Papyra always satisfies it
© 2026 Stefan Nikolei. Payments are processed by Paddle.com as merchant of record.