Font issue on CentOS

I have a specific document that has an issue when converting each page to an image. The font is Calibri and is converted to Asian/Chinese looking characters.

aspose.docx.zip (296.0 KB)

The conversion is being done on a CentOS machine using Aspose Words 18.4 on Java.

When logging warnings during the save / image conversion process, I get this message:
Font ‘Wingdings’ has not been found. Using ‘Webdings’ font instead. Reason: closest match according to font info from the document.

However the font is Calibri and not Wingdings.

When I ask Aspose to use Arial for missing fonts, it still does not work and I get the same result, but this warning message:
Font ‘Wingdings’ has not been found. Using ‘Arial’ font instead. Reason: default font setting.

When I copy all the fonts from a Windows 10 system and rebuild the font cache, I get no warning messages, but the same result during the conversion.

@friksa,

Thanks for your inquiry.

Please note that Aspose.Words requires TrueType fonts when rendering document to fixed-page formats (JPEG, PNG, PDF or XPS). You need to install fonts that are used in your document on the machine where you’re converting documents to PDF. Please refer to the following article:

How Aspose.Words Uses True Type Fonts

Your document contains the “Wingdings” font. Please check the attached image. font Wingdings.png (32.4 KB)

If you face any issue with output document, please attach the following resources here for testing:

  • Please attach the output PDF/image file that shows the undesired behavior.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Converting this document on a Windows or Mac system works perfectly. It only fails on CentOS.

This is the resulted conversion:
aspose.zip (311.0 KB)

This is the code that was used:

		Document o  = new Document(fn);
		int      count = o.getPageCount();

		for (int i = 0; i < count; i++)
		{
			String	png	= dir+"/" + i + ".png";
			ImageSaveOptions opt = new ImageSaveOptions(SaveFormat.PNG);
			opt.setPageIndex(i);
			opt.setPageCount(1);

			o.save(png, opt);
		}

@friksa,

Thanks for sharing the detail. We have tested the scenario using latest version of Aspose.Words for Java 18.5 at Ubuntu operating system and have not found the shared issue. Please use Aspose.Words for Java 18.5. Please make sure that you have installed all fonts used in your document at the machine where you are converting document to PNG.

I have upgraded to 18.5 and the result is still the same. How do I collect more detailed debugging information to figure out what is going wrong?

My pom.xml contains:

        <repository>
            <id>aspose-maven-repository</id>
            <url>http://artifact.aspose.com/repo/</url>
        </repository>

and

        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-words</artifactId>
            <version>18.5</version>
            <classifier>jdk16</classifier>
        </dependency>

CentOS Java version
java -version
openjdk version “1.8.0_171”
OpenJDK Runtime Environment (build 1.8.0_171-b10)
OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)

This is the output from fc-list showing all installed fonts:
fc-list.txt.zip (5.0 KB)

@friksa,

Thanks for sharing the detail. Aspose.Words for Java depends upon the Java Advanced Imaging (JAI) package from Oracle in order to process some image formats. Please install JAI package at your end and let us know if you still face problem.
Additional Dependencies

If you still face problem, please save your document to PDF and share the output PDF here for further investigation. Thanks for your cooperation.

I followed the instructions for Additional Dependencies and the results are still the same when creating PNG images.

I used this code to create the PDF:
o.save(dir + “/aspose.docx.pdf”, SaveFormat.PDF);

The PDF fonts look great, but not the PNG images.
aspose.docx.pdf (230.1 KB)

Thanks!

If I convert the doc to PDF and then convert the PDF pages to PNG, it looks great. But when I go directly from DOCX to PNG images, it is messed up.

Here is the zip file containing the png images from doc and then inside the pdf folder the png images from the pdf (that was created from the doc).
pdf2png.zip (592.5 KB)

@friksa,

Thanks for sharing the detail. We have not found the shared issue while using the code example shared here. Please copy the fonts from Windows and use FontSettings.SetFontsFolder.

  • Please make sure that you are using the same code example.
  • Are you using the same document shared in this thread.
  • Is this issue appeared for the specific document or with all documents?
  • Could you please convert the document to images at some other Linux operating system and share your findings?

I am always using the same document when responding to this thread. We have converted a few other documents on this CentOS system without problems. This is the first document with a problem.

  • if we modify the font of the text in this document to Arial, it converts fine on this CentOS system
  • setting the fontFolder directly to the windows folder makes no difference:
FontSettings fontSettings = FontSettings.getDefaultInstance();
fontSettings.setFontsFolder("/usr/share/fonts/win", true);

Running the same code and using the same document on Debian works (even without the need to copy fonts from a windows system since we installed the windows fonts):
debian.zip (424.4 KB)

If I copy the same windows fonts folder to the Debian system and set the fontsFolder to it, it still works great. You can see that even the wingding arrows works (compared to the previous convert that replaced it with another character).
debian-winfonts.zip (326.5 KB)

Same code, same document, same fonts works great in Windows, Mac, Debian, but not on CentOS.

@friksa,

Thanks for sharing the detail. We are setting up the same environment as of yours and will test the same scenario at our end. Please spare us some time for the investigation of this issue. We will get back to you soon.

Thanks! This is a Amazon EC2 server running CentOS
Amazon Linux AMI release 2018.03

Please let me know what other details you need.

@friksa,

We will test this scenario at CentOS and share our findings with you. Thanks for your cooperation.

Are you able to recreate the issue? Thanks!

@friksa,

Thanks for your patience. We have setup CentOS and OpenJDK 1.8 at our end. We have tested the scenario and have not found the shared issue. Please check the attached output images. output images.zip (326.5 KB)

We have used following code example to test this case. The fonts folder is copied from Windows 10. We suggest you please use FontSettings as shown below. Hope this helps you.

FontSettings fs = new FontSettings();
fs.setFontsFolder("/home/tahir/Fonts", true);

LoadOptions options = new LoadOptions();
options.setFontSettings(fs);
Document o  = new Document("/home/tahir/inputDocs/aspose.docx", options);
int      count = o.getPageCount();

for (int i = 0; i < count; i++)
{
    String	png	= "/home/tahir/output/out_" + i + ".png";
    ImageSaveOptions opt = new ImageSaveOptions(SaveFormat.PNG);
    opt.setPageIndex(i);
    opt.setPageCount(1);

    o.setWarningCallback(new IWarningCallback() {
        @Override
        public void warning(WarningInfo warningInfo) {
            if (WarningType.FONT_EMBEDDING == warningInfo.getWarningType()
                    || WarningType.FONT_SUBSTITUTION == warningInfo.getWarningType()) {
                System.out.println(warningInfo.getDescription());
            }
        }
    });
    o.save(png, opt);
}

Using exactly the same code still causes the issue for us. How do we troubleshoot this? There has to be a way to get more debugging information out of the tool.

@friksa,

As per our understanding, you are facing the issue only with one document (aspose.docx) that has text with “Calibri” font. Please confirm if this is correct.

Could you please do the following tests and share your findings?

  • Please download the document from this forum thread and use the same code.
  • Please create new document Calibri font and export it to image using same code.
  • Please re-save aspose.docx using MS Word and export the output DOCX to image using same code.
  • Please execute the same code at some other CentOS operating system using same code.

We really appropriate your cooperation.