We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Glyph-based Fonts are not Substituted as Expected (Java)

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 with Times 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 font Symbol.
    • We require a specific font to be used as the replacement font.
  • Replacement with Glyph-based Font: When we specify a glyph-based font (such as Webdings or Wingdings) as the replacement font, the substitution seems to work. Additionally the WarningCallback 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!

@oraspose,

We have carried investigation on our end. Actually, the symbol U+F0E0 that has been used from font Glyphdings in your presentation is not available in Times New Roman. Therefore, no substitution occurred. In other words, it’s not possible to use Times New Roman for this symbol, and Aspose.Slides forces the substitution.

We have some default substitution handling for symbol fonts, so this symbol U+F0E0 will be substituted to the other corresponding symbol font by default (if Glyphdings is not available). If this is symbol font (what is detected based on the Unicode range) and required font is not present it will be substituted with Wingdings, or if it’s not present - with OpenSymbol.

Thank you for your helpful reply Mudassir.

We have some follow-up questions:

  1. Can we assume that the FontFallBackRule functionality may work for us - as long as we provide a set of fonts that have the Unicode character that the glyph/symbol represents?

  2. In a scenario where the JRE does not have any glyph-based fonts (such as Wingdings or OpenSymbol) with the necessary Unicode range - how does Slides determine the “default substitution handling”?
    We are seeing that different fonts are used for substitutions under different JRE environments (for the same Presentation).
    For example, in one environment, the glyph-based font is substituted with the font MS Gothic - but in another it is substituted with DejaVu Serif - even though MS Gothic is available on both systems and we’ve specified that the glyph-based font should always be substituted with MS Gothic.

  3. Given #2 above, is there any way to predict what font Slides will use for the substitution of the glyph-based font?

Thanks again.

@oraspose,

The question shared are pertaining to internal API working mechanism and we need to investigate it further on our end. A ticket with ID SLIDESJAVA-38134 has been created to further investigate these requirements. We will get back to you with a feedback as soon as issue will be addressed.