FontsManager

FontsManager class

Manages fonts across the presentation.

public class FontsManager : IFontsManager

Properties

NameDescription
FontFallBackRulesCollection { get; set; }Represents a user’s collection of FontFallBack rules for managing of collections of fonts for proper substitutions by fallback functionality Read/write IFontFallBackRulesCollection.
FontSubstRuleList { get; set; }Font substitutions to use when rendering. Read/write IFontSubstRuleCollection.

Methods

NameDescription
AddEmbeddedFont(byte[], EmbedFontCharacters)Adds the embedded font Keep in mind when copying any fonts that most fonts are copyrighted. First locate the license of a font before hand and verify they can be freely transferred to another machine.An ArgumentException can be thrown if font data is null or this font is already embedded
AddEmbeddedFont(IFontData, EmbedFontCharacters)Adds the embedded font Keep in mind when copying any fonts that most fonts are copyrighted. First locate the license of a font before hand and verify they can be freely transferred to another machine.An ArgumentException can be thrown if font data is null or this font is already embedded
GetEmbeddedFonts()Returns the fonts embedded in the presentation
GetFonts()Returns the fonts used in the presentation
GetSubstitutions()Gets the information about fonts that will be replaced on the presentation’s rendering.
RemoveEmbeddedFont(IFontData)Removes the embedded font
ReplaceFont(IFontSubstRule)Replace font in presentation using information provided in FontSubstRule
ReplaceFont(IFontSubstRuleCollection)Replace font in presentation using information provided in collection of FontSubstRule
ReplaceFont(IFontData, IFontData)Replace font in presentation

Examples

The following example shows how to add embedded fonts to PowerPoint Presentation.

[C#]
// Load presentation
using (Presentation presentation = new Presentation("Fonts.pptx"))
{
	// Load source font to be replaced
	IFontData sourceFont = new FontData("Arial");
	IFontData[] allFonts = presentation.FontsManager.GetFonts();
	IFontData[] embeddedFonts = presentation.FontsManager.GetEmbeddedFonts();
	foreach (IFontData font in allFonts)
	{
		if (!embeddedFonts.Contains(font))
		{
			presentation.FontsManager.AddEmbeddedFont(font, EmbedFontCharacters.All);
		}
	}
	// Save the presentation
	presentation.Save("AddEmbeddedFont_out.pptx", SaveFormat.Pptx);
}

See Also