GemBox.Document
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    FontSettings Class

    Namespace:
    GemBox.Document
    Assembly:
    GemBox.Document.dll

    Contains font related settings which are used when printing, importing or exporting a document to a file format that requires font information.

    • C#
    • VB.NET
    public static class FontSettings
    Public Module FontSettings
    Inheritance:
    Object
    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.

    • C#
    • VB.NET
    public static IList<FontFile> Fonts { get; }
    Public Shared ReadOnly Property Fonts As IList(Of FontFile)
    Property Value
    IList<FontFile>

    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().

    • C#
    • VB.NET
    public static string FontsBaseDirectory { get; set; }
    Public Shared Property FontsBaseDirectory As String
    Property Value
    String

    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.

    • C#
    • VB.NET
    public static string FontsBaseResourceLocation { get; set; }
    Public Shared Property FontsBaseResourceLocation As String
    Property Value
    String

    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.

    Packaging Fonts in Windows application

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

    Packaging Fonts in Web application

    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 fontFontsBaseResourceLocationNotes
    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
    Packaging Fonts with Applications
    Pack URIs in WPF

    FontsBaseUri

    Gets or sets the base Uri where component looks for fonts. Uri path should end with DirectorySeparatorChar or AltDirectorySeparatorChar.

    • C#
    • VB.NET
    public static Uri FontsBaseUri { get; set; }
    Public Shared Property FontsBaseUri As Uri
    Property Value
    Uri

    The base 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).

    • C#
    • VB.NET
    public static event EventHandler<FontFileSelectionEventArgs> FontSelection
    Public Shared Event FontSelection As EventHandler(Of FontFileSelectionEventArgs)
    Event Type
    EventHandler<FontFileSelectionEventArgs>
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.