menu

WPF

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SubstituteFontEventArgs - WPF API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SubstituteFontEventArgs

    Inheritance
    System.Object
    System.EventArgs
    SubstituteFontEventArgs
    Inherited Members
    System.EventArgs.Empty
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Syncfusion.Presentation
    Assembly: Syncfusion.Presentation.Base.dll
    Syntax
    public class SubstituteFontEventArgs : EventArgs

    Properties

    AlternateFontName

    Gets or sets the alternate font name.

    Declaration
    public string AlternateFontName { get; set; }
    Property Value
    Type Description
    System.String

    The string that specifies the alternate font name.

    Examples
    //Load the PowerPoint presentation and convert to image
    IPresentation pptxDoc = Presentation.Open("Sample.pptx");
    // Initializes the 'SubstituteFont' event to set the replacement font
    pptxDoc.FontSettings.SubstituteFont += FontSettings_SubstituteFont;
    //Converts the first slide into image
    Image image = pptxDoc.Slides[0].ConvertToImage(Syncfusion.Drawing.ImageType.Metafile);
    //Disposes the image
    image.Dispose();
    //Close the presentation.
    pptxDoc.Close();
    /// 
    /// Sets the alternate font when a specified font is unavailable in the production environment
    /// 
    /// FontSettings type of the Presentation in which the specified font is used but unavailable in production environment. 
    /// Retrieves the unavailable font name and receives the substitute font name for conversion. 
    private static void FontSettings_SubstituteFont(object sender, SubstituteFontEventArgs args)
    {
        if (args.OriginalFontName == "Arial Unicode MS")
            args.AlternateFontName = "Arial";
        else if (args.OriginalFontName == "Calibri Light")
            args.AlternateFontName = "Calibri";
        else
            args.AlternateFontName = "TimesNewRoman";
    }
     'Load the PowerPoint presentation and convert to image
     Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
     'Initializes the 'SubstituteFont' event to set the replacement font
     AddHandler pptxDoc.FontSettings.SubstituteFont, AddressOf SubstituteFont
     'Convert the PowerPoint presentation to image.
     Dim image As Image = pptxDoc.Slides(0).ConvertToImage(Syncfusion.Drawing.ImageType.Metafile)
     'Dispose the image
     image.Dispose()
     'Close the Presentation.
     pptxDoc.Close()
     ''' 
     ''' Sets the alternate font when a specified font is unavailable in the production environment
     ''' 
     ''' FontSettings type of the Presentation in which the specified font is used but unavailable in production environment. 
     ''' Retrieves the unavailable font name and receives the substitute font name for conversion. 
     Private Sub SubstituteFont(ByVal sender As Object, ByVal args As SubstituteFontEventArgs)
         ' Sets the alternate font when a specified font is not installed in the production environment
         If args.OriginalFontName = "Arial Unicode MS" Then
             args.AlternateFontName = "Arial"
         ElseIf args.OriginalFontName = "Calibri Light" Then
             args.AlternateFontName = "Calibri"
         Else
             args.AlternateFontName = "Times New Roman"
         End If
     End Sub

    AlternateFontStream

    Declaration
    public Stream AlternateFontStream { get; set; }
    Property Value
    Type
    System.IO.Stream

    FontStyle

    Declaration
    public FontStyle FontStyle { get; }
    Property Value
    Type
    System.Drawing.FontStyle

    OriginalFontName

    Gets the original font name. Read Only.

    Declaration
    public string OriginalFontName { get; }
    Property Value
    Type Description
    System.String

    The string that specifies the original font name.

    Examples
    //Load the PowerPoint presentation and convert to image
    IPresentation pptxDoc = Presentation.Open("Sample.pptx");
    // Initializes the 'SubstituteFont' event to set the replacement font
    pptxDoc.FontSettings.SubstituteFont += FontSettings_SubstituteFont;
    //Converts the first slide into image
    Image image = pptxDoc.Slides[0].ConvertToImage(Syncfusion.Drawing.ImageType.Metafile);
    //Disposes the image
    image.Dispose();
    //Close the presentation.
    pptxDoc.Close();
    /// 
    /// Sets the alternate font when a specified font is unavailable in the production environment
    /// 
    /// FontSettings type of the Presentation in which the specified font is used but unavailable in production environment. 
    /// Retrieves the unavailable font name and receives the substitute font name for conversion. 
    private static void FontSettings_SubstituteFont(object sender, SubstituteFontEventArgs args)
    {
        if (args.OriginalFontName == "Arial Unicode MS")
            args.AlternateFontName = "Arial";
        else if (args.OriginalFontName == "Calibri Light")
            args.AlternateFontName = "Calibri";
        else
            args.AlternateFontName = "TimesNewRoman";
    }
     'Load the PowerPoint presentation and convert to image
     Dim pptxDoc As IPresentation = Presentation.Open("Sample.pptx")
     'Initializes the 'SubstituteFont' event to set the replacement font
     AddHandler pptxDoc.FontSettings.SubstituteFont, AddressOf SubstituteFont
     'Convert the PowerPoint presentation to image.
     Dim image As Image = pptxDoc.Slides(0).ConvertToImage(Syncfusion.Drawing.ImageType.Metafile)
     'Dispose the image
     image.Dispose()
     'Close the Presentation.
     pptxDoc.Close()
     ''' 
     ''' Sets the alternate font when a specified font is unavailable in the production environment
     ''' 
     ''' FontSettings type of the Presentation in which the specified font is used but unavailable in production environment. 
     ''' Retrieves the unavailable font name and receives the substitute font name for conversion. 
     Private Sub SubstituteFont(ByVal sender As Object, ByVal args As SubstituteFontEventArgs)
         ' Sets the alternate font when a specified font is not installed in the production environment
         If args.OriginalFontName = "Arial Unicode MS" Then
             args.AlternateFontName = "Arial"
         ElseIf args.OriginalFontName = "Calibri Light" Then
             args.AlternateFontName = "Calibri"
         Else
             args.AlternateFontName = "Times New Roman"
         End If
     End Sub
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved