Click or drag to resize
Pdf Library for .NET

PdfSystemFonts Class

Discovery of fonts installed on the host system. Works on Windows, Linux and macOS.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfSystemFonts

Namespace: SelectPdf.Universal
Assembly: SelectPdf.HtmlToPdf.Universal (in SelectPdf.HtmlToPdf.Universal.dll) Version: 26.4
Syntax
public static class PdfSystemFonts

The PdfSystemFonts type exposes the following members.

Properties
 NameDescription
Public propertyStatic memberInstalledFamilies Returns every font family installed on the host system, sorted alphabetically and de-duplicated case-insensitively. Cached after the first call.
Top
Methods
 NameDescription
Public methodStatic memberIsFamilyInstalled Returns true if a font family with the specified name is installed on the host system. Case-insensitive.
Public methodStatic memberLoadFontBytes Resolves a system font to its raw font-file bytes (TrueType / OpenType). Throws PdfDocumentException if the family isn't installed or its bytes can't be read.
Top
Remarks

Use InstalledFamilies to enumerate every installed family name, and IsFamilyInstalled(String) to test for a specific family. Pass a resolved family name to Add(PdfSystemFont) or CreateFromSystemFont(String, Single) to load and embed it into a document.

The installed-family list is read from the host OS the first time it is accessed and cached for the lifetime of the process. Fonts installed after that point won't appear.

Example
foreach (string family in PdfSystemFonts.InstalledFamilies)
    System.Console.WriteLine(family);

if (PdfSystemFonts.IsFamilyInstalled("Arial"))
{
    byte[] bytes = PdfSystemFonts.LoadFontBytes("Arial", PdfFontStyle.Bold);
}
See Also