Font Substitution Does Not Occur when Converting PPT to PDF in Java

Hello,

I am working on font substitution topic when converting ppt to PDF on WINDOWS 10.
I have PPT where “Arial” font is used, while conversion to PDF I want to substitute “Arial” font to “Comic Relief” font (font installed on my WINDOWS machine). Below is code for font substitution.

IFontData sourceFontArial = new FontData("Arial");
IFontData destFontComic = new FontData("Comic Relief");
IFontSubstRule fontSubstRule = new FontSubstRule(sourceFontArial, destFontComic,
        FontSubstCondition.Always);

IFontSubstRuleCollection slidesFontSettings = new FontSubstRuleCollection();
slidesFontSettings.add(fontSubstRule);

com.aspose.slides.LoadOptions pptLoadOptions = AsposeConfig.getSlidesLoadOptions();
WarningCallbackSlides warningCallbackSlides = new WarningCallbackSlides();          // class created for warning callback
pptLoadOptions.setWarningCallback(warningCallbackSlides);
Presentation presentation = new Presentation(sourceFilePath, pptLoadOptions);
presentation.getFontsManager().setFontSubstRuleList(slidesFontSettings);
presentation.save(outputFilePath, SaveFormat.Pdf);

Here issue I am facing:
- PDF is generated, but Font from “Arial” to “Comic Relief” is not substituted.
- I am getting warning callback from aspose saying : "Font will be substituted from Comic Relief to {Arial,Cambria Math,MS Gothic,Gulim,Arial Unicode,SimSun,Segoe UI Symbol,DejaVu Sans,Liberation Serif,FreeSans}

Please help me if I am doing anything wrong.

Note: This substitution issue is happening with any windows font, I have taken “Arial” font for example purpose. substitution is working correctly “Arial” to “Calibri” without any warning.

@dnyandevp,
Thank you for contacting support.

Please check your results using the latest version of Aspose.Slides for Java if it is possible. If the issue persists, please share the following data and information:

  • input presentation file
  • output PDF file
  • complete code example that reproduces the problem (please note that the code example above uses unknown classes)
  • JDK version in your app
  • Aspose.Slides version you used

Hello,
As per your comment, I tried to validate the result with latest version of Aspose Slides for java v23.1 but issue still persist.

I am sharing below details in Files.zip.

  • Input Presentation file “FontTest_Arial.pptx”
  • Output PDF file “FontTest_Arial.pdf”.
  • Complete code example “FontSubstitute.java”
  • JDK Version : jdk-17.0.3.1
  • Aspose Slides (tested with v22.3 AND v23.1)

Please note, WarningCallback was not working when I upgrade Aspose Slides version to v23.1.
Please let me know if I am doing anything wrong.
Files.zip (53.8 KB)

Thanks in advance

@dnyandevp,
Thank you for the files and information. I found that there are different binaries of the Comic Relief font you mentioned. Could you please also share the font from your operating system?

comic-relief.zip (44.4 KB)
Please find attached “comic-relief.zip” for Comic Relief font

@dnyandevp,
Thank you for the font file. I reproduced the problem with the font substitution.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESJAVA-39120

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

As a workaround, you can use the FontsLoader.loadExternalFonts method and specify the folder to custom fonts as shown below. It will help.

FontsLoader.loadExternalFonts(new String[] { fontFolderPath });

Documents: Custom Font

Thanks for your quick response.
I tried to load external fonts using workaround as explained above and which is working fine.
But I am facing another issue that, WarningCallback is not working when I upgrade Aspose slide version to latest V23.1, (you can refer same example shared in last post). I can able to get WarningCallback when I use older aspose slide version V22.3.
Could you please let me know if I am doing anything wrong.
Thanks in advance.

@dnyandevp,
Font replacement warnings appear when Aspose.Slides has to replace a missing font with another one. In your case, this does not happen.

Documents: Getting Warning Callbacks for Fonts Substitution in Aspose.Slides

I shared above code just for example purpose. You can change font name in example, so that it will throw warning. I tried but it is not throwing any warning.
Could you please check?

@dnyandevp,
Thank you for the explanation. I reproduced the problem with disappearing the warning in Aspose.Slides 23.1.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESJAVA-39121

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thank you for your quick response.
Please let me know if there is any workaround for this issue.

@dnyandevp,
I forwarded your request to our developers.

@dnyandevp,
As for the issue SLIDESJAVA-39120, our developers were unable to reproduce the problem with the font substitution when Comic Relief font is installed on the operating system. Could you please check the availability of Comic Relief font from your app?

Thanks for your response. SLIDESJAVA-39120 issue resolved at my end as well. Issue was specific to my system. I tried on different machine and it is working.

What about SLIDESJAVA-39121 issue, I still not able to get warning callback even though fonts are replaced?

@dnyandevp,
The SLIDESJAVA-39121 issue has not been scheduled for investigation yet. We apologize for any inconvenience.

Hello,

Please share if you have updates on ticket SLIDESJAVA-39121.
Thank you in advance…

@dnyandevp,
The issue SLIDESJAVA-39121 has not been resolved yet. Unfortunately, I don’t have any other information. You will be notified when the issue is resolved.

@dnyandevp,
As for the SLIDESJAVA-39121 issue, the substitution message occurs at the moment of saving the presentation. In this case, you should use SaveOptions like this:

SaveOptions saveOptions = new PdfOptions();
saveOptions.setWarningCallback(new WarningCallbackSlides());
Presentation pres = new Presentation("FontTest_Arial (1).pptx");
try {
    pres.save("output.pdf", SaveFormat.Pdf, saveOptions);
} finally {
    if (pres != null) pres.dispose();
}