FontSettings Class
Contains font related settings which are used when printing, importing or exporting a document to a file format that requires font information.
- Inheritance:
- FontSettings
Remarks
Setting the custom fonts location is usually used in medium trust environments to bypass file system operations restrictions imposed for file locations that are not under the application's jurisdiction.
For more information, see private fonts example.
Properties
Fonts
Gets all the fonts loaded in the current application domain that are usable with GemBox.Document component.
public static IList<FontFile> Fonts { get; }
Public Shared ReadOnly Property Fonts As IList(Of FontFile)
Property Value
All the fonts loaded in the current application domain that are usable with GemBox.Document component.
FontsBaseDirectory
Gets or sets the base directory path where component looks for fonts. Directory path can be absolute or relative to GetCurrentDirectory().
public static string FontsBaseDirectory { get; set; }
Public Shared Property FontsBaseDirectory As String
Property Value
The base directory path where component looks for fonts.
Remarks
If you are developing ASP.NET application, then use Server.MapPath(System.String) to set the FontsBaseDirectory.
FontsBaseResourceLocation
Gets or sets the base resource location where component looks for fonts specified as resources inside the local or referenced assembly.
Read Remarks for details about the format of the FontsBaseResourceLocation for desktop and web applications.
public static string FontsBaseResourceLocation { get; set; }
Public Shared Property FontsBaseResourceLocation As String
Property Value
The base resource location where component looks for fonts specified as resources inside the local or referenced assembly.
Remarks
important
When you add fonts as resources to your application, make sure you are setting the <Resource> element when targeting .NET Framework or when targeting .NET Core with enabled WPF.
Otherwise, use <EmbeddedResource> element for the build action.
Following image shows an example of a Windows Console project structure with font files added as resources.

Following table illustrates the various base resource locations that you can specify to use fonts from the above Windows Console project structure.
Resource locations consist of required and adjustable parts.
Used font | FontsBaseResourceLocation | Notes |
---|---|---|
Font1.ttf | "/" | Font resource files are in the root of local assembly. |
Font2.ttf | "/MyFonts/" | Font resource files are in the subfolder of local assembly. |
Font3.ttf | "/MyClassLibrary;component/" | Font resource files are in the root of referenced assembly. |
Font4.ttf | "/MyClassLibrary;component/MyFonts/" | Font resource files are in the subfolder of referenced assembly. |
Following image shows an example of a Web ASP.NET project structure with font files added as resources.

Following table illustrates the various base resource locations that you can specify to use fonts from the above Web ASP.NET project structure.
Since ASP.NET assembly is actually a class library referenced from ASP.NET web server, resource location must always include ;component part.
Used font | FontsBaseResourceLocation | Notes |
---|---|---|
Font1.ttf | "/MyWebApplication;component/" | Font resource files are in the root of local assembly. |
Font2.ttf | "/MyWebApplication;component/MyFonts/" | Font resource files are in the subfolder of local assembly. |
Font3.ttf | "/MyClassLibrary;component/" | Font resource files are in the root of referenced assembly. |
Font4.ttf | "/MyClassLibrary;component/MyFonts/" | Font resource files are in the subfolder of referenced assembly. |
See Also
FontsBaseUri
Gets or sets the base System.Uri where component looks for fonts. System.Uri path should end with DirectorySeparatorChar or AltDirectorySeparatorChar.
Property Value
- System.Uri
The base System.Uri where component looks for fonts.
Events
FontSelection
Occurs when the FontFile must be selected based on the font name, style and weight used in the document and when the fallback font must be selected (if the current FontFile does not contain outlines for the Character).
public static event EventHandler<FontFileSelectionEventArgs> FontSelection
Public Shared Event FontSelection As EventHandler(Of FontFileSelectionEventArgs)