Class FontProvider

Namespace
SoftZenPdf.Layout
Assembly
SoftZenPdf.dll

Finds fonts by family name for laid-out text (FlowDocument) and for converted documents: the families you register, fonts found in folders or on the system, and the 14 standard fonts as the last resort.

public sealed class FontProvider
Inheritance
FontProvider
Inherited Members

Remarks

A family list such as "Calibri, Arial, sans-serif" is tried in order. The generic families serif, sans-serif and monospace try common fonts of each kind and end with Times, Helvetica or Courier. A family with no bold or italic face uses its regular face, drawn slightly heavier or slanted.

A character the chosen font cannot show is looked for in FallbackFamilies, then in every registered font; if none has it, it is replaced by a question mark and reported. Fonts found by scanning are loaded only when first used. One provider can be shared by many documents.

Constructors

FontProvider()

Creates a provider that knows only the 14 standard fonts, until you add others.

Properties

DefaultFamily

The family used when none of a requested list is available, and for text with no family. Defaults to sans-serif. For PDF/A documents, set it to a registered TrueType family: standard fonts cannot be used there.

FallbackFamilies

Families tried, in order, for characters the requested font cannot show (for example a CJK or emoji font).

Families

The family names of every registered font, standard fonts included.

Methods

Add(TrueTypeFont, string?, bool?, bool?)

Registers a loaded font under its own family name (or family), as its bold and italic style.

AddAlias(string, string)

Makes family resolve to target (a family or family list), for example to substitute a font you do not have.

AddFile(string)

Registers every font of a font file (each font of a .ttc collection). Fonts are loaded when first used.

AddFolder(string, bool)

Registers every usable font in a folder (.ttf, .ttc and .otf files).

AddSystemFonts()

Registers the fonts installed on this computer: the Windows fonts folders, /usr/share/fonts and the user's font folders on Linux, and the font folders of macOS.

GetFont(string?, bool, bool)

The font for a family list and style, as text would use it.

HasFamily(string)

Whether a family is registered (standard font families included).