Font Substitution Questions

I've got some questions about font substitutions. We are running Aspose.Slides for Java on a Unix system that has only 3 fonts installed by default - DejaVu Sans, DejaVu Serif and DejaVu Mono. This is leading to some poorly rendered images when we convert the Presentation files to JPEGs. This becomes more of an issue when it comes to documents with Japanese, Chinese and Korean fonts as the DejaVu fonts don't have those characters we get boxes instead of characters.
I've implemented the WarningCallback which reports all kinds of font substitutions occurring for my document and since there are only 3 fonts it always uses DejaVu Serif. We'd like to add more fonts to our system preferably free/open source ones. Is there documentation on which fonts should be installed that will adhere to your default font substitution settings. Also are there any plans to implement a font substitution API similar to what Aspose.Words has that would allow us to tweak the default font substitutions if need be.

Thanks, Ian.

Hi Ian,

I am unable to understand you issue completely. Could you please share some more details and some samples to give us a better understanding of your issue. If you are looking for using custom / external fonts, please see the following documentation link.

Use Custom fonts without installing them

Thanks & Regards,

The issue is that I have a PowerPoint presentation with that was created on a Windows computer and uses the fonts that are available with Windows and Office, (e.g. MS Gothic for Japanese). We are processing the presentation with Aspose.Slides on a Unix computer that doesn’t have access to the font provided by Microsoft on the Windows computer. For the Japanese font I have 2 different fonts (Sazanami Gothic and TakaoPGothic). I have loaded those fonts using FontsLoader.loadExternalFonts API but they are not used when converting the presentation to JPEG or PDF. I get empty boxes for the Japanese characters (see attached). Aspose.Words recognizes the TakaoPGothic as a valid substitute for MS Gothic.

What I’d like to know is that if I don’t have the actual font used in the presentation what I can use as substitute for it?



Thanks, Ian.

Hi Ian,

Thank you for the feedback.

I have created a new feature request in our issue tracking system with issue id: SLIDESJAVA-34478. Our development system will further look into the feasibility of this issue.

Thanks & Regards,

Hi,


I’ve done some more testing, using some more fonts and got some better results. I download some CJK for Unix from here: https://help.ubuntu.com/community/Fonts#Chinese.2C_Japanese.2C_and_Korean_Fonts. This seemed to solve the missing characters in my Japanese font and Chinese font documents converted to PDF, but not my Korean font documents. However, slides saved as JPEG via getThumbnail() and ImageIO.write() still have the empty boxes for the CJK characters for a documents.
I’ve attached a ZIP file with the test documents and the output JPEGs and PDFs from my testing.
The code I uses is this:
public class PowerPointToImage {
static {
File fontFile = new File(“~/CJK-Fonts/UnTaza.ttf”);
FontsLoader.loadExternalFonts(new String[]{unicodeFontFile.getParent()});
}

public static void main(String[] args) {
try {
File file = new File(args[0]);
Presentation presentation = new Presentation(file.getInputStream());
ISlide slide = presentation.getSlides().get_Item(0);
BufferedImage targetImage = slide.getThumbnail(1.0f, 1.0f);

String rootPath = System.getProperty(“user.home");
File dir = new File(rootPath + File.separator + “tmpFiles”);
long jpgFilename = System.currentTimeMillis();

LOGGER.info(“Save PPT as JPEG);
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(serverFile));
ImageIO.write(targetImage, “jpeg”, stream);
stream.close();

LOGGER.info(“Save PPT as PDF”);
long pdfFileName = System.currentTimeMillis();
File serverFile3 = new File(dir.getAbsolutePath() + File.separator + String.valueOf(pdfFileName) + “.pdf”);

PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setWarningCallback(new WarningCallback());
presentation.save(serverFile3.getAbsolutePath(), pdfSaveOptions);
} catch (Exception e) {
LOGGER.error(“PowerPoint conversion error”, e);
}
}

Thanks, Ian.

Hi Ian,

Thank you for the feedback.

We will further look into your shared details and will get back to you soon.

Thanks & Regards,

One more question about loading external fonts the release notes for Aspose.Slides 8.7.0 and for 14.5.0 say that this minor feature is there:

  • (SLIDESJAVA-34250) - FontLoader should give the names of externally loaded fonts
Where is it implemented? I can’t find the method that shows the externally loaded fonts. FontsLoader.loadExternalFonts() is a void method.

Thanks, Ian.

Hi Ian,

Thank you for the feedback.

You can verify loading of fonts in JVM by using standard java.awt.GraphicsEnvironment class. Please see the following sample code:

Font[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();


Thanks & Regards,

I have another question about setting font folders with FontsLoader.

Are the fonts collected recursively when using loadExternalFonts or does it only look at the folder passed in.

E.g.
Folder Structure:
~/MyFonts (contains font files)
~/MyFonts/Japanese (contains more font files)

File fontFolder = new File("~/MyFonts");
FontsLoader.loadExternalFonts(new String[] {fontFolder.getAbsolutePath()} );

With the code above will loadExternalFonts find the fonts in both the folders MyFonts and MyFonts/Japanese or just MyFonts?

Thanks, Ian.

Hi Ian,

I am checking your requested feature and will get back to you shortly.

Thanks & Regards,

I’ve got another quick question about the font usage. When putting the fonts on the Unix computer, is it good enough to just use say Arial, or should I use all the styles, Arial Bold, Arial Italic, Arial Bold Italic.

Will Aspose.Slides use Java APIs to bold/italicize a font if only the regular style is present on the computer?

Thanks, Ian.

Hi Ian,

Sorry for the delay in response.

I have asked the development team to further look into your queries and share their feedback. An issue has been registered for feedback in our issue tracking system with id: SLIDESJAVA-34511. I will share the feedback of the development team as soon as I get the response.

Thanks & Regards,

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Ian,

Regarding issue id: SLIDESJAVA-34478, please try the following sample code and see if it works fine for you.

LoadOptions loadOptions = new LoadOptions();
loadOptions.setDefaultAsianFont(“TakaoPGothic”);
Presentation pres = new Presentation(presentationName, loadOptions);
Please do let us know in case you need any further assistance.

Thanks & Regards,

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi
I am setting font dir to my local folder for Slides
FontsLoader.loadExternalFonts( new String [] { “local_dir” } );

gettign UnsatisfiedLinkError : awt.dll is not a valid win32 application.

I am using java10 and Asopose-slides-14.6.0

And the same issue is getting for below code as well
Font[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();

Please suggest me any workaround.

@dhawal,

I have observed that you are using a very old version of Aspose.Slides. Please first try using Aspose.Slides for Java 18.6 on your and if there is still an issue then please share the issue details along with sample application, Operating System and Java details on your end.

This issue was not occurred when I used with Tomcat 64bit and Java10.
But One-thing I saw, Some JDK internal APIs are used All Aspose Java libraries.
These JDK internal APIs are no longer available for general use.
So when we can expect latest Aspose java libraries which will be compatible with java 10+ ?

Thanks

@dhawal,

I have observed your question related to Java 10 support and like to share that at present the support is not available. An issue with ID SLIDESJAVA-37004 has already been created in our issue tracking system to provide requested support. We will share updates with you as soon the issue will be fixed.