Specify Fallback Fonts for Presentations in Python via Java

Overview

Aspose.Slides allows you to specify fallback fonts for presentation rendering and export operations. Fallback fonts are used when the primary font does not contain glyphs for particular characters.

Fallback behavior is configured through fallback rules. Each rule associates a Unicode range with one or more fonts that may contain the required glyphs. You can define rules for different character ranges, add or remove fallback fonts from existing rules, and organize multiple rules in a fallback font rules collection.

Fallback rules are runtime rendering settings. They do not modify the presentation file itself and are not stored inside the PPTX file.

Fallback Rules

Aspose.Slides provides the FontFallBackRule class to specify rules for applying fallback fonts. This class represents an association between a Unicode range used to search for missing glyphs and a list of fonts that may contain the required glyphs:

import jpype
import asposeslides

if not jpype.isJVMStarted():
    jpype.startJVM()

from asposeslides.api import FontFallBackRule

start_unicode_index = 0x0B80
end_unicode_index = 0x0BFF

first_rule = FontFallBackRule(start_unicode_index, end_unicode_index, "Vijaya")
second_rule = FontFallBackRule(0x3040, 0x309F, "MS Mincho, MS Gothic")

# Use multiple ways to specify a list of fonts.
font_names = jpype.JArray(jpype.JString)(["Segoe UI Emoji, Segoe UI Symbol", "Arial"])

third_rule = FontFallBackRule(0x1F300, 0x1F64F, font_names)

You can also remove a fallback font using remove or add fallback fonts using addFallBackFonts in an existing FontFallBackRule object.

FontFallBackRulesCollection can organize a list of FontFallBackRule objects when you need to specify fallback font replacement rules for multiple Unicode ranges.

FAQ

What is the difference between a fallback font, font substitution, and font embedding?

A fallback font is used only for characters missing in the primary font. Font substitution replaces the entire specified font with another font. Font embedding packages the fonts inside the output file so recipients can view the text as intended.

Are fallback fonts applied during exports like PDF, PNG, or SVG, or only on-screen rendering?

Yes. Fallback affects all rendering and export operations where characters must be drawn but are absent in the source font.

Does configuring fallback change the presentation file itself, and will the setting persist for future openings?

No. Fallback rules are runtime rendering settings in your code; they are not stored inside the .pptx and won’t appear in PowerPoint.

Does the operating system (Windows/Linux/macOS) and the set of font directories affect fallback selection?

Yes. The engine resolves fonts from available system folders and any additional paths you provide. If a font isn’t physically available, a rule referencing it cannot take effect.

Does fallback work for WordArt, SmartArt, and charts?

Yes. When these objects contain text, the same glyph-substitution mechanism applies to render missing characters.