在 Android 上配置回退字体集合

Apply Fallback Rules

实例 FontFallBackRule 类可以组织到 FontFallBackRulesCollection 中,它实现了 IFontFallBackRulesCollection 接口。可以向集合中添加或删除规则。

然后可以将此集合分配给 FontsManager 类的 FontFallBackRulesCollection 方法。FontsManager 控制整个演示文稿中的字体。了解更多 About FontsManager and FontsLoader

每个 Presentation 都有一个 getFontsManager 方法,返回其自己的 FontsManager 实例。

下面是一个示例,演示如何创建回退字体规则集合并将其分配到特定演示文稿的 FontsManager 中:

Presentation pres = new Presentation();
try {
    IFontFallBackRulesCollection userRulesList = new FontFallBackRulesCollection();

    userRulesList.add(new FontFallBackRule(0x0B80, 0x0BFF, "Vijaya"));
    userRulesList.add(new FontFallBackRule(0x3040, 0x309F, "MS Mincho, MS Gothic"));

    pres.getFontsManager().setFontFallBackRulesCollection(userRulesList);
} finally {
    if (pres != null) pres.dispose();
}

在使用回退字体集合初始化 FontsManager 后,回退字体将在演示文稿渲染过程中应用。

FAQ

Will my fallback rules be embedded into the PPTX file and visible in PowerPoint after saving?

不会。回退规则是运行时渲染设置;它们不会序列化到 PPTX 中,也不会出现在 PowerPoint 的 UI 中。

Does fallback apply to text inside SmartArt, WordArt, charts, and tables?

是的。这些对象中的任何文本都使用相同的字形替换机制。

Does Aspose distribute any fonts with the library?

不会。您需要自行添加和使用字体,责任自行承担。

Can replacement/substitution for missing fonts and fallback for missing glyphs be used together?

可以。它们是同一字体解析管线的独立阶段:首先引擎解析字体可用性(replacement/substitution),然后回退为可用字体中缺失的字形填补空缺。