Aspoe.Slide Font substitution is not rendering non-latin character based languages correctly (Java)

Hi Aspose -

We running into problem rendering presentations that are using non-latin characters using Aspose.Slides.

We’ve setup a simple program that takes a presentation and outputs a PDF as follows:

            LoadOptions loadOptions = new LoadOptions();
            loadOptions.setWarningCallback(new WarningCallback());
            Presentation doc = new Presentation(filename, loadOptions);

            PdfOptions options = new PdfOptions();
            options.setWarningCallback(new WarningCallback());
            doc.save(outputFilename, SaveFormat.Pdf, options);

We output the warnings with the following code:

class WarningCallback implements IWarningCallback {
    @Override
    public int warning(IWarningInfo warningInfo) {
        System.out.println("Warning: " + warningInfo.getDescription());
        return ReturnAction.Continue;
    }
}

The presentation is created on a Window computer and being rendered on a Linux computer. The Windows and Linux computer does not have the same fonts installed, but the Linux computer has fonts that can be used as fallbacks for every language in the presentation.

However when we load and render presentations we see that a lots of font substitutions to fonts that does not properly support the languages. In other words Aspose.Slides is not picking the best font for the text that needs to be rendered.

We are currently facing problems rendering characters for the following languages:

  • Chinese (Simplified)
  • Chinese (Traditional)
  • Japanese
  • Korean
  • Punjabi
  • Thai
  • Tamil
  • Urdu
  • Hindi

Attached is sample code: AsposeSlidesTest.zip (322.6 KB).

To build run:

./gradlew shadowJar 

To run:

java -jar build/libs/AsposeSlidesTest-1.0-all.jar Languages.pptx encoding.pdf

Here is an example of the rendered outcome: encoding.pdf (157.5 KB)

1 Like

@sbd,

I have observed your comments. Can you please environment details along with which Aspose.Slides version you are using on your end so that we may further investigate to help you out.

Yes, Ubuntu 14.04 running Aspose.Slides 18.9.

@sbd,

I have observed your comments. Can you please try to use Aspose.Slides latest version 18.10 on your end and share your feedback with us.

Using Aspose.Slides 18.10 produces the same results. See output: encoding.pdf (157.3 KB).

@sbd,

I have worked with the sample code shared by you and have been able to observe the issue. An issue with ID SLIDESJAVA-37404 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

The issues you have found earlier (filed as SLIDESJAVA-37404) have been fixed in this update.

@Adnan.Ahmad,
I have retested using version 18.12 of Aspose Slides and I am still able to reproduce the problem where Aspose Slides is not picking the correct font. I do not see any difference after upgrading to 18.12.

Please advise if I need to do something differently when converting to PDF, or if you can also still reproduce the problem.

Upgraded code zip: AsposeSlidesTest.zip (353.6 KB)

@sbd,

If the required fonts are not available, tyou can use the following workarounds:

Use LoadOptions. LoadOptions contains 3 methods, that we created specially for situations where the required fonts are not available.

LoadOptions loadOptions = new LoadOptions();
loadOptions.setDefaultRegularFont("font name"); //Sets Regular font used in case source font is not found.
loadOptions.setDefaultAsianFont("font name"); //Sets Asian font used in case source font is not found.
loadOptions.setDefaultSymbolFont("font name"); //Sets Symbol font used in case source font is not found.

Presentation pres = new Presentation("source.pptx", loadOptions);

Use FontsManager.replaceFont(). This method allow to replace one specific font with another.

Presentation pres = new Presentation("source.pptx");

IFontData sourceFont = new FontData("Calibri");
IFontData destFont = new FontData("DejaVu Sans");
pres.getFontsManager().replaceFont(sourceFont, destFont);

I hope the shared information will be helpful.

@mudassir.fayyaz,

Thanks for getting back to us so fast. Unfortunately we’re not able to use any of the suggested methods for the following reasons.

  • LoadOptions.setDefaultAsainFont
    There is not one font that contains the glyphs of all the east asian language that we need to support. There are typically separate fonts for Simplified Chinese, Traditional Chinese, Japanese and Korean so it’s unclear how this would work. At the time of rendering we do not know which languages are used in the presentation, and a presentation may use multiple Asian languages.

  • FontsManager.replaceFont
    We do not have an exhaustive list of fonts that our users may use, so it is not possible to setup replacement fonts. Furthermore some of the Windows based fonts contains different glyph-sets than their open source alternatives, therefore there does not exists a one-to-one mapping between the fonts, some may have a one-to-many mapping based on glyphs.

We are looking for a functionality similar to the Aspose Word Font Fallback functionality outlined here: Font Fallback in Aspose.Words.

How can we achieve this in Aspose Slides?

@sbd,

I have observed your requirements and regret to inform that this is not supported yet. A ticket with ID SLIDESJAVA-37469 has been created as in our issue tracking system as a new feature request. We will look into the possibility of implementation of the requested feature. This thread has been associated with this new feature request, so that you can be automatically notified as soon as this issue is resolved.

@sbd,

I like to inform that we have investigated issue in details and we need some information for further investigation. Can you please share initial conditions for this issue. We need to know unambiguously whether you can specify the limited list of fonts which contains a whole set of glyphs which will cover all necessary substitutions or you are expecting that our code itself has to reconsider available fonts in a system and to choose the most suitable fonts for missed glyphs. Can you please describe in general the technical specification/demands and entry conditions.

The initial conditions are this:

  • User provides presentation using any fonts and in any language (or multiple languages)
  • Our system renders the presentation using Aspose slides. We expect Aspose slides to replace any font not available on the rendering system with an equivalent font that is available.

The font selection mechanism could work like this:

  1. Try to find a font on the file system with an exact font name match

    • If font is available confirm font can render the unicode code points in the text
  2. If font is not found, or font cannot render code points repeat step 1 for each replacement fonts specified by powerpoint

  3. If no font is found that can render text use fallback.xml file to select font (similar to Aspose word)

@sbd,

Thanks for sharing requested information. We will get back to you with good news soon.

Has there been any progress on this issue. We have a similar use case and are experiencing the same problem.

@rob.riding,

I like to inform that we are working on this and will share good news with you soon.

The issues you have found earlier (filed as SLIDESJAVA-37469) have been fixed in this update.