Hello,
We need to substitute glyph-based fonts (such as Wingdings
or Webdings
) with a non-glyph-based font such (such as Times New Roman
). However, Slides’ font replacement APIs seem to work with other glyph-based fonts only.
This behavior can be seen in the latest Aspose Slides for Java version 20.5, the attached GlyphFontSubstitution.pptx
file and the following Java code:
final String pptxFile = [PATH] + "GlyphFontSubstitution.pptx";
final IWarningCallback loadCallback = new IWarningCallback() {
@Override
public int warning(IWarningInfo warning) {
System.out.println("* Got Warning Callback:\n " + warning.getDescription());
return ReturnAction.Continue;
}
};
// Replace 'Glyphdings' with 'Times New Roman'
final IFontSubstRuleCollection fontSubsRules = new FontSubstRuleCollection();
fontSubsRules.add(new FontSubstRule(new FontData("Glyphdings"),
new FontData("Times New Roman"),
FontSubstCondition.Always));
LoadOptions loadOptions = new LoadOptions();
Presentation ppt = new Presentation(pptxFile, loadOptions);
// Set the Font Substitution Rule
ppt.getFontsManager().setFontSubstRuleList(fontSubsRules);
System.out.println("\n* Callback messages from Presentation SAVE:");
loadOptions.setWarningCallback(loadCallback);
ppt.save(pptxFile.replace(".pptx", ".pdf"), SaveFormat.Pdf, new PdfOptions());
Running the above code should produce the following Console output:
* Callback messages from Presentation SAVE:
* Got Warning Callback:
Font will be substituted from Times New Roman to {Franklin Gothic Medium Cond,Arial,MS Gothic,Gulim,Arial Unicode}
Key Observations:
-
Replacement Font Substituted: Even though we specified the
Glyphdings
font to be replaced withTimes New Roman
, it was replaced by a different font.- This is confirmed by the console output from the
WarningCallback
. - In our environment, the
Glyphdings
font was replaced by the fontSymbol
. - We require a specific font to be used as the replacement font.
- This is confirmed by the console output from the
-
Replacement with Glyph-based Font: When we specify a glyph-based font (such as
Webdings
orWingdings
) as the replacement font, the substitution seems to work. Additionally theWarningCallback
produces no messages (as expected). -
FontFallBack Functionality: We also looked at the FontFallBackRule functionality (as described by the 19.10 Release Notes). However, it does not seem to to fix the issue described above.
If you think this is a viable solution for us - would you be able to provide an example by expanding the sample code above that might work?
Environment Details:
- Aspose Slides for Java 20.5
- Java version 1.8.0_211
- Windows 10 OS (but also reproducible under Linux).
File description in the GlyphFontSubstitution.zip (60.0 KB) attachment:
- GlyphFontSubstitution.pptx: Presentation with single slide used by code above.
- GlyphFontSubstitution.pdf: PDF output file produce from the code above.
Thank you!