Skip to content

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"));

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 PDF 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.

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.

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.

  • Styling and colors - where FontFamily fits into style inheritance
  • PDF/A output - font embedding is required for PDF/A, and Papyra always satisfies it