Table of Contents

Class GlobalFontSettings

Namespace
PdfSharp.Fonts
Assembly
PdfSharp.dll

Provides functionality to specify information about the handling of fonts in the current application domain.

public static class GlobalFontSettings
Inheritance
object
GlobalFontSettings

Fields

DefaultFontName

The name of the default font. This name is obsolete and must not be used anymore.

Properties

DefaultFontEncoding

Gets or sets the default font encoding used for XFont objects where encoding is not explicitly specified. If it is not set, the default value is PdfFontEncoding.Automatic. If you are sure your document contains only Windows-1252 characters (see https://en.wikipedia.org/wiki/Windows-1252) set default encoding to PdfFontEncoding.WinAnsi. Must be set only once per app domain.

FallbackFontResolver

Gets or sets the fallback font resolver for the current application. This static function must be called only once and before any font operation was executed by PDFsharp. If this is not easily to obtain, e.g. because your code is running on a web server, you must provide the same instance of your font resolver in every subsequent setting of this property.

FontResolver

Gets or sets the custom font resolver for the current application. This static function must be called only once and before any font operation was executed by PDFsharp. If this is not easily to obtain, e.g. because your code is running on a web server, you must provide the same instance of your font resolver in every subsequent setting of this property.

UseSystemFonts

Gets or sets whether the Core build uses the fonts installed on the machine when no custom FontResolver is set. The default is true. FreePDF asks the Windows font table (if UseWindowsFontsUnderWindows or UseWindowsFontsUnderWsl2 is set) and the FallbackFontResolver first, then the folders added with AddFontDirectory(string), then the system's font folders. A common family that is not installed, such as Arial or Courier New, is replaced by a font with the same widths (Liberation Sans, Liberation Mono) or else by a common font of the same kind (DejaVu Sans), and a warning is logged. Only TrueType fonts whose licence allows embedding are used. Set it to false before the first font is used to require a custom font resolver, as PDFsharp 6.2.4 did. A custom font resolver gives fully reproducible output on every machine.

UseWindowsFontsUnderWindows

Gets or sets a value that defines what to do if the Core build of PDFsharp runs under Windows. If true, PDFsharp uses the build-in WindowsPlatformFontResolver to resolve some standards fonts like Arial or Times New Roman if the code runs under Windows. If false, which is default, you must provide your own custom font resolver. We recommend to use always a custom font resolver for a PDFsharp Core build.

UseWindowsFontsUnderWsl2

Gets or sets a value that defines what to do if the Core build of PDFsharp runs under WSL2. If true, PDFsharp uses the build-in WindowsPlatformFontResolver to resolve some standards fonts like Arial or Times New Roman if the code runs under WSL2. If false, which is default, you must provide your own custom font resolver. We recommend to use always a custom font resolver for a PDFsharp Core build.

Methods

AddFontDirectory(string)

Adds a folder of font files, for example fonts deployed with the application, that the Core build searches before the system's font folders when no custom FontResolver is set. Subfolders are searched too. Families that were already used keep the font they resolved to.

ResetFontManagement()

Shortcut for PdfSharpCore.ResetFontManagement.