Exception "Cannot Find Any Font Installed on the System" while Loading Fonts in Java

My application which is using Aspose Slides 17.10.0 is running on Red Hat Linux OS.
Using FontsLoader.loadExternalFonts() I am passing in a font directory containing say for example Calibri.ttf. The Linux OS did not have Calibri.

However, I do see the Calibri getting added to the Graphic Environment because of FontsLoader.loadExternalFonts() call:

GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()

But, I still get cannot find any fonts installed on the system.

What kind of permissions does Aspose expect the font .ttf file to have?
I am curious to know if this is already fixed in a future release ?
Just so you know, my code DOES work fine on windows and I am trying to create a new ppt in my application.

ERROR:-

class com.aspose.slides.exceptions.InvalidOperationException: Cannot find any fonts installed on the system.
com.aspose.slides.internal.dh.native.do(Unknown Source)
com.aspose.slides.m8.do(Unknown Source)
com.aspose.slides.m8.do(Unknown Source)
com.aspose.slides.m8.do(Unknown Source)
com.aspose.slides.agh.do(Unknown Source)
com.aspose.slides.mq.do(Unknown Source)
com.aspose.slides.j4.do(Unknown Source)
com.aspose.slides.nd.do(Unknown Source)
com.aspose.slides.ah4.for(Unknown Source)
com.aspose.slides.ah4.switch(Unknown Source)
com.aspose.slides.cv.do(Unknown Source)
com.aspose.slides.BaseSlide.do(Unknown Source)
com.aspose.slides.Slide.do(Unknown Source)
com.aspose.slides.Slide.do(Unknown Source)
com.aspose.slides.z0.try(Unknown Source)
com.aspose.slides.z0.do(Unknown Source)
com.aspose.slides.Presentation.do(Unknown Source)
com.aspose.slides.Presentation.do(Unknown Source)
com.aspose.slides.Presentation.do(Unknown Source)
com.aspose.slides.Presentation.save(Unknown Source)

Please advice!
Thanks in advance.

1 Like

@krithikam589,

I have observed your comments. Can you please share sample project so that we may further investigate to help you out. I also like to suggest that please try to use Aspose.Slides latest version on your end before sharing requested information.

Hi Adnan,
Yes, as mentioned I have updated the Aspose.Slides to 18.6 and tried running the below code on Linux server within a java web application. But I still get the font not found error as in my first comment above.

String path = servletContext.getRealPath(“WEB-INF/classes/aspose/fonts/CALIBRI.TTF”);
path = path.substring(0, path.lastIndexOf(’/’));
FontsLoader.loadExternalFonts(new String[] {path});
FontsLoader.clearCache();
String[] fontsAvailable = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
String templateFilePath = servletContext.getRealPath(“resources/aspose/Sample.pptx”);
final LoadOptions loadOptions = new LoadOptions(LoadFormat.Auto);
Presentation pptPresentation = new Presentation(templateFilePath,loadOptions);
String dataDir = “/tmp/”;
pptPresentation.save(dataDir + “NewSample.pptx”, com.aspose.slides.SaveFormat.Pptx);

Just so you know, /usr/shared/fonts or any other default font folder mentioned in /etc/fonts/fonts.config for Linux does not have any .ttf font file.
I am expecting to load external fonts without depending on the Linux system to have any fonts at root level.
Can you please try this test case and let me know what you see ? This seems to be a bug with the Aspose Slides library.

Thanks in advance,
Krithika

@krithikam589,

I have worked with sample code using Aspose.Slides for Java 18.7 and unable to observe any issue. Can you please share source presentation for further investigation. Also please try to use Aspose.Slides latest version 18.7 on your end before sharing requested file.

@Adnan.Ahmad
As suggested I have updated to 18.7 and still observe the issue. Can you please make sure you test on a Linux server and also not have any fonts on that server (eg. fc-list command should not return any fonts).
Also, /usr/shared/fonts or any other default font folder mentioned in /etc/fonts/fonts.config on the Linux server should not have any .ttf font file.

Would really appreciate if you could have your development team check the code where the below error is popping from:
class com.aspose.slides.exceptions.InvalidOperationException: Cannot find any fonts installed on the system.
com.aspose.slides.internal.dh.native.do(Unknown Source)

This specific error strongly makes me think that somewhere in the library the default folders are still being checked instead of looking at externally loaded font path.

FYI, “WEB-INF/classes/aspose/fonts/” external font path in my above code has all Calibri font files (6 .ttf files for Calibri) not just one.

Thanks,
Krithika

@krithikam589,

I have observed your comments. An issue with ID SLIDESJAVA-37312 has been created in our issue tracking system to investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.

@Adnan.Ahmad thanks you, hope to see this issue fixed soon.

Also please use the above shared sample code as part of your investigation to confirm the above code works. Hoping to see this issue fixed sooner since my organization has already purchased the license and we are unable to proceed with using this library until this issue is fixed.

@krithikam589,

I have observed the issue status from our issue racking system and like to share that it is pending owing to already added issues. We will share updates with you as soon as the issue will be scheduled and fixed.

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

Hi @Adnan.Ahmad, @mudassir.fayyaz , I still do see the issue after upgrading to 18.8 and I am still getting the below error:

class com.aspose.slides.exceptions.InvalidOperationException: Cannot find any fonts installed on the system.
com.aspose.slides.internal.lw.public.do(Unknown Source)
com.aspose.slides.nq.do(Unknown Source)
com.aspose.slides.nq.do(Unknown Source)
com.aspose.slides.nq.do(Unknown Source)
com.aspose.slides.ahv.do(Unknown Source)
com.aspose.slides.m0.do(Unknown Source)
com.aspose.slides.kn.do(Unknown Source)
com.aspose.slides.nw.do(Unknown Source)
com.aspose.slides.aji.for(Unknown Source)
com.aspose.slides.aji.default(Unknown Source)
com.aspose.slides.ajf.do(Unknown Source)
com.aspose.slides.ajf.(Unknown Source)
com.aspose.slides.TextFrame.do(Unknown Source)
com.aspose.slides.TextFrame.do(Unknown Source)
com.aspose.slides.TextFrame.char(Unknown Source)
com.aspose.slides.q.do(Unknown Source)
com.aspose.slides.pt.do(Unknown Source)
com.aspose.slides.pt.do(Unknown Source)
com.aspose.slides.bb.do(Unknown Source)
com.aspose.slides.wa.if(Unknown Source)
com.aspose.slides.abo.do(Unknown Source)
com.aspose.slides.abo.do(Unknown Source)
com.aspose.slides.Presentation.do(Unknown Source)

Can you please check if the code shared by me in the above comments works or not for version 18.8 ?

@krithikam589,

I have observed your comments. Can you please share complete environment details with us for further investigation.

Hi @Adnan.Ahmad, The operating system is RHEL6.10 (Linux). So please try running the above shared code on this operating system and make sure the default font paths mentioned in /etc/fonts/fonts.config file, do not have any .ttf files.
Also, fc-list command when run on the terminal should not return any font names.

@krithikam589,

Thank you for sharing the information. Can you please provide information about Java version used on your end as some Java versions have issues with Calibri fonts.

4 posts were split to a new topic: Problem with rendering of barcode in document

@dananorth,
Welcome to our community! If you encounter any problems while working with our products or you have any suggestions, please post a new thread on the forum.