Configure Fallback Font Collections in Python via Java
Overview
Aspose.Slides allows you to configure a collection of fallback font rules for a presentation. Each fallback rule is represented by the FontFallBackRule class and can be added to a FontFallBackRulesCollection.
After creating the collection, you can assign it using the setFontFallBackRulesCollection method of the presentation’s FontsManager. The FontsManager controls fonts across the presentation, and each Presentation instance has its own FontsManager.
Once the FontsManager is initialized with the fallback font collection, the specified fallback fonts are applied during presentation rendering.
Apply Fallback Rules
Instances of the FontFallBackRule class can be organized into a FontFallBackRulesCollection. You can add or remove rules from the collection.
This collection can then be assigned using the setFontFallBackRulesCollection method of the FontsManager class, which controls fonts across the presentation.
Each Presentation has a getFontsManager method that returns its own instance of the FontsManager class.
The following example shows how to create a fallback font rules collection and assign it to the FontsManager of a presentation:
import jpype
import asposeslides
if not jpype.isJVMStarted():
jpype.startJVM()
from asposeslides.api import FontFallBackRule, FontFallBackRulesCollection, Presentation
presentation = Presentation()
try:
fallback_rules = FontFallBackRulesCollection()
tamil_rule = FontFallBackRule(0x0B80, 0x0BFF, "Vijaya")
fallback_rules.add(tamil_rule)
hiragana_rule = FontFallBackRule(0x3040, 0x309F, "MS Mincho, MS Gothic")
fallback_rules.add(hiragana_rule)
presentation.getFontsManager().setFontFallBackRulesCollection(fallback_rules)
finally:
presentation.dispose()
After the FontsManager is initialized with the fallback font collection, the fallback fonts are applied during presentation rendering.
Note
Read more about how to render a presentation with a fallback font.FAQ
Will my fallback rules be embedded into the PPTX file and visible in PowerPoint after saving?
No. Fallback rules are runtime rendering settings; they are not serialized into PPTX and will not appear in PowerPoint’s UI.
Does fallback apply to text inside SmartArt, WordArt, charts, and tables?
Yes. The same glyph-substitution mechanism is used for any text in these objects.
Does Aspose distribute any fonts with the library?
No. You add and use fonts on your side and under your own responsibility.
Can replacement/substitution for missing fonts and fallback for missing glyphs be used together?
Yes. They are independent stages of the same font-resolution pipeline: first the engine resolves font availability (replacement/substitution), then fallback fills gaps for missing glyphs in available fonts.