Exception "FontFamily 'Courier New' not found" on converting EMF to PNG using Aspose.Imaging for Java

Hi all,

I try to convert EMF to png on linux and I receive the following error:

Caused by: class com.aspose.imaging.internal.Exceptions.ArgumentException: FontFamily ‘Courier New’ not found
Parameter name: Courier New
com.aspose.imaging.internal.ao.p.(Unknown Source)
com.aspose.imaging.internal.at.a.a(Unknown Source)
com.aspose.imaging.internal.O.g.(Unknown Source)
com.aspose.imaging.internal.S.c.a(Unknown Source)
.
.
.

My code is:
Image image = Image.load(file.getPath(), new MetafileLoadOptions(true));
EmfRasterizationOptions emf = new EmfRasterizationOptions();
emf.setPageHeight(image.getHeight());
emf.setPageWidth(image.getWidth());
PngOptions options = new PngOptions();
options.setVectorRasterizationOptions(emf);
image.save(file.getPath().replace(".emf", “.png”), options);

if I install the specified font on linux it works perfect, but I want to use one of the following options without to install manually fonts e.g under the path /usr/share/fonts/truetype:

  1. FontSettings.addFontsFolder(fontFolder);
  2. FontSettings.addFontSubstitutes(“Courier New”, new String[] {“a font that is available on linux”});
  3. FontSettings.setDefaultFontName(fontName);

why none of the above options doesn’t work? Could you please help/advise me.

@pkouras,

I have observed your comments. Can you please share source files along with complete environment details and also please share which Aspose.Imaging version you are using on your end so that we may further investigate to help you out.

LINUX
Description: SUSE Linux Enterprise Server 12
Release: 12

ASPOSE

com.aspose
aspose-imaging
18.4
jdk16

EMF file
image9.zip (1.9 KB)

@pkouras,

I have observed your comments. Can you please try to use Aspose.Imaging latest version 18.6 on your end and share feedback with us if there is still an issue.

unfortunately the same issue.

I tried also the following commands but nothing.

  1. FontSettings.setFontsFolder(“a custom folder where COUR.TTF is available”);
  2. FontSettings.setFontSubstitutes(“Courier New”, new String[] { “Luxi Mono” }); where Luxi Mono a font which is available in the default folder(/usr/share/fonts/truetype) on linux.

@pkouras,

As suggested earlier, can you please try using latest Aspose.Imaging for Java 18.6 on your end and share your feedback with us if there is still an issue.

sorry I didn’t exactly write it but the results in my previous comment were with 18.6.
same issue in both 18.4 and 18.6

@pkouras,

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

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