FontsManager

FontsManager class

管理演示文稿中的字体。

public class FontsManager : IFontsManager

Properties

名称描述
FontFallBackRulesCollection { get; set; }表示用户的字体备份规则集合,用于管理集合中的字体,以便通过后备功能进行适当替换。可读写 IFontFallBackRulesCollection
FontSubstRuleList { get; set; }渲染时使用的字体替换。可读写 IFontSubstRuleCollection

Methods

名称描述
AddEmbeddedFont(byte[], EmbedFontCharacters)添加嵌入字体。请注意,复制任何字体时,大多数字体是受版权保护的。请事先找到字体的许可证并验证它们是否可以自由转移到另一台机器。如果字体数据为null或该字体已经嵌入,可能会抛出 ArgumentException。
AddEmbeddedFont(IFontData, EmbedFontCharacters)添加嵌入字体。请注意,复制任何字体时,大多数字体是受版权保护的。请事先找到字体的许可证并验证它们是否可以自由转移到另一台机器。如果字体数据为null或该字体已经嵌入,可能会抛出 ArgumentException。
GetEmbeddedFonts()返回在演示文稿中嵌入的字体。
GetFontBytes(IFontData, FontStyle)检索表示指定字体样式和字体数据的字节数组。
GetFontEmbeddingLevel(byte[], string)从给定的字节数组和字体名称确定字体的嵌入级别。
GetFonts()返回演示文稿中使用的字体。
GetSubstitutions()获取关于将在演示文稿渲染中被替换字体的信息。
RemoveEmbeddedFont(IFontData)移除嵌入字体。
ReplaceFont(IFontSubstRule)使用 FontSubstRule 中提供的信息替换演示文稿中的字体。
ReplaceFont(IFontSubstRuleCollection)使用 FontSubstRule 的集合中提供的信息替换演示文稿中的字体。
ReplaceFont(IFontData, IFontData)替换演示文稿中的字体。

Examples

以下示例演示如何将嵌入字体添加到 PowerPoint 演示文稿中。

[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