FontSettings.addFontsFolder only loads TTF fonts


I found that Aspose.Imaging wasn’t finding MS Gothic when attempting to render an EMF containing Japanese text.

It turns out that when you call FontSettings.addFontsFolder, it doesn’t find MS Gothic because MS Gothic is a TTC (TrueType Collection), and Aspose.Imaging is only looking for files ending in “.ttf”.

This is in the obfuscated code of Aspose, in com.aspose.imaging.B:

private void a(File var1) throws IOException, FontFormatException {
File[] var2 = var1.listFiles();
File[] var3 = var2;
int var4 = var2.length;

for(int var5 = 0; var5 < var4; ++var5) {
File var6 = var3[var5];
if(var6.isDirectory()) {
} else if(var6.getName().toLowerCase().endsWith(“ttf”)) {
Font var7 = Font.createFont(0, var6);


This code is clearly not going to find the TTC files since it requires the name to end in “ttf”, but I also worry that it’s using java.awt.Font to create the font here, as this probably won’t find the font, as Java won’t know about it either.

(On a separate note, calls to String.toLowerCase() without passing a Locale are generally very dangerous. Although perhaps in this particular instance it might be safe, it’s safest to avoid using this method entirely. It would be worth getting calls to this removed from all libraries just in case. In this particular case, Locale.ROOT should have been passed in.)

Hi Nicholas,

Thank you for your inquiry and sharing details.

This is to update you that an investigation ticket has been logged into our system with ID IMAGINGJAVA-643. All information has also been shared with our product team. Our product team will further look into it and provide feedback. We will update you with the feedback in this thread once available.


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

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


Seems like I get the same results under v17.4. EmfMetafileImage#getMissedFonts() returns {“MS Gothic”}, same as before, and the resulting image looks the same.

Attaching the EMF we used, as well as the font. Maybe the library failed to parse the font, or something like that?


Hi Nicholas,

I have worked with file shared by you using Aspose.Imaging for Java 17.4 and unable to observe the issue.

Please try using the attached sample code. You can place the MS Gothic font in your computer directory somewhere. By using sample code, you have option to load the fonts externally using FontSettings.setFontsFolder(Fontpath) method. You can try setting the font folder and render the EMF to PDF. Then you can try generating the PDF without setting the fonts folder and you will observe the difference. I have attached the generated PDF file on my end for your reference as well.

The shared code will help you to achieve your requirements. Please share feedback with us if there is still an issue.

Best Regards,


Ah, I believe this helps reproduce a different problem that I hadn’t noticed yet. Our own code had caught the exception and proceeded, which hid the real problem…

Exception in thread “main” class com.aspose.imaging.coreexceptions.FrameworkException: Font name not found —> java.awt.FontFormatException: Font name not found
— End of inner exception stack trace —
com.aspose.imaging.FontSettings.setFontsFolders(Unknown Source)
com.aspose.imaging.FontSettings.setFontsFolders(Unknown Source)
at com.aspose.imaging.FontSettings.setFontsFolders(Unknown Source)
at com.aspose.imaging.FontSettings.setFontsFolders(Unknown Source)
at com.nuix.integration.TestEmf.main(
Caused by: java.awt.FontFormatException: Font name not found
at sun.font.TrueTypeFont.init(
at sun.font.TrueTypeFont.(
at sun.font.TrueTypeFont.(
at sun.font.CFontManager.createFont2D(
at java.awt.Font.(
at java.awt.Font.createFont(
at com.aspose.imaging.z.a(Unknown Source)
at com.aspose.imaging.z.(Unknown Source)
… 3 more

I’m attaching the font which it failed on.


Hi Nicholas,

Thanks for sharing further details with us.

I have tested the EMF file shared by you using code sample given in Testemf.txt and have been able to reproduce the exception. A ticket with ID IMAGINGJAVA-692 has been added in our issue tracking system to resolve the issue. This thread has been linked with ticket so that you may be notified once issue will be fixed.

We are sorry for your inconvenience,


The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.


We have tried updating to the latest version of Aspose.Imaging and the problem is still there. I think maybe the fix notification was for another issue as it mentions Aspose.Words.



I have observed your comments. Can you please try to follow below procedure.

  1. Remove all fonts “Ms Mincho” from system.
  2. Download font file and copy to any folder.
  3. Execute this code.

EmfRecorderGraphics2D graphics = new EmfRecorderGraphics2D(new Rectangle(0,0,150,150),new Size(15000,15000),new Size(150,150) );
Font font = new Font(“MS Mincho”, 20);
graphics.drawString(“MS Mincho”,font, Color.getBlue(), 0, 50);
EmfImage image = graphics.endRecording();
PdfOptions bmpOptions = new PdfOptions();
bmpOptions.setVectorRasterizationOptions(new EmfRasterizationOptions()