Hebrew Fonts not rendering correctly after upgrading Aspose on Windows

We recently upgraded aspose from version 19.3 to version 22.9 on our Windows server. Hebrew characters now don’t render at all when converting txt to pdf, showing up as the character often seen in place of unicode characters that fail to load. We have a large number of Fonts installed on the servers, including david.tff and frank.tff.

The relavent code in our service is:

PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.setSaveFormat(SaveFormat.PDF);
saveOptions.setJpegQuality(75);
saveOptions.setTextCompression(PdfTextCompression.FLATE);
baos = new ByteArrayOutputStream();
doc.save(baos, saveOptions);
return baos.toByteArray();

I can follow up with the Fonts loaded on startup.

1 Like

@ysaadi Could you please attach your problematic document and output here for testing? We will check the issue and provide you more information.

hebrew_lorem.txt.zip (1.8 KB)

I got an error when trying to upload the file, so I zipped it first.

the output is:
93-offer-letter.pdf (6.4 KB)

@ysaadi It seems that there are no required font available to Aspose.Words on your server. Particularly Aspose.Words tries to use “Times New Roman” font for the Hebrew text. Please check Specify TrueType Fonts Location article. You could check the fonts availability by GetAvailableFonts method or you could use warnings to check that font substitution appeared. If you do not have access to Windows/Office fonts, you could use Google Noto fonts as an free alternative.

I used this code to print the fonts we load:

for (FontSourceBase fontSourceBase : defaultInstance.getFontsSources()) {
StringBuilder builder = new StringBuilder();
builder.append(String.format(“FontSourceBase: Type: %d, Priority: %d%n”, fontSourceBase.getType(), fontSourceBase.getPriority()));
if (fontSourceBase.getAvailableFonts() != null) {
for (PhysicalFontInfo physicalFontInfo : fontSourceBase.getAvailableFonts()) {
builder.append(String.format("\tPhysicalFontInfo FontFamily: %s, FullName: %s, FilePath: %s, Version: %s%n",
physicalFontInfo.getFontFamilyName(), physicalFontInfo.getFullFontName(),
physicalFontInfo.getFilePath(), physicalFontInfo.getVersion()));
}
}

There are two sources of fonts. One loaded from windows machine and one bundled with our service. Both were priority 0.

PhysicalFontInfo FontFamily: Times New Roman, FullName: Times New Roman Bold Italic, FilePath: D:\platform\template\template_test860\WEB-INF\classes\conf\fonts\Times New Roman Bold Italic.ttf, Version: Version 5.00.3x
PhysicalFontInfo FontFamily: Times New Roman, FullName: Times New Roman Bold, FilePath: D:\platform\template\template_test860\WEB-INF\classes\conf\fonts\Times New Roman Bold.ttf, Version: Version 5.01.3x
PhysicalFontInfo FontFamily: Times New Roman, FullName: Times New Roman Italic, FilePath: D:\platform\template\template_test860\WEB-INF\classes\conf\fonts\Times New Roman Italic.ttf, Version: Version 5.00.3x
PhysicalFontInfo FontFamily: Times New Roman, FullName: Times New Roman, FilePath: D:\platform\template\template_test860\WEB-INF\classes\conf\fonts\Times New Roman.ttf, Version: Version 5.01.3x
PhysicalFontInfo FontFamily: Times New Roman, FullName: Times New Roman, FilePath: C:\Windows\Fonts\times.ttf, Version: Version 6.96
PhysicalFontInfo FontFamily: Times New Roman, FullName: Times New Roman Bold, FilePath: C:\Windows\Fonts\timesbd.ttf, Version: Version 6.96
PhysicalFontInfo FontFamily: Times New Roman, FullName: Times New Roman Bold Italic, FilePath: C:\Windows\Fonts\timesbi.ttf, Version: Version 6.96
PhysicalFontInfo FontFamily: Times New Roman, FullName: Times New Roman Italic, FilePath: C:\Windows\Fonts\timesi.ttf, Version: Version 6.96

here are the times related tffs:
times_tffs.zip (2.1 MB)

I can get you the whole output for the loaded fonts and a zip file of all the fonts on our windows machine + what we package with our service. I notice that what we package with is a bit outdated, not sure if that can cause anything.

@ysaadi You have attached the “Times New Roman” fonts version 6.96 from the system. Could you please also attach the “Times New Roman” fonts version 5.0… bundled with your service?

sure.
times_bundled.zip (1.6 MB)

@ysaadi Unfortunately I still cannot reproduce the problem on my side. The provided “Times New Roman” fonts are properly used by Aspose.Words for the Hebrew text (see test.awjava.22.12.pdf (19.2 KB)).

Could you please create a small test project which will use a single FolderFontSource and a minimum set of fonts so the problem will be reproduced on your side?

Aspose is used for a fairly large number of documents of diverse type. Disabling a large chunk of our fonts can have unintended/unforeseeable consequences. Is there any way to pinpoint which exact font was used for a document conversion? I can provide you with the full set of fonts that we load from both font sources, but I would need a way to give it to you since the zip is over the 50 mb limit for upload here.
Meanwhile, I’ll try to test removing some fonts that seem related to hebrew to see if that can be the cause of the issue. I’m also relatively certain that this has happened before with a much smaller aspose library version upgrade. I’ll test that this morning, so we can maybe just look at patch notes and guess what could be causing this. Here’s one candidate: Aspose.Words for .NET 19.4 Release Notes

I was able to verify that the 19.3 version of aspose worked, and the 19.4 version did not. So it is likely exactly the following patch note that caused this to break:
https://docs.aspose.com/words/net/aspose-words-for-net-19-4-release-notes/#changes-in-font-resolving-while-loading-html-svg-document

@ysaadi Thanks for sharing the details. Unfortunately we cannot proceed with the issue until we will be able to reproduce it in test environment. You could upload the fonts pack onto some file hosting service like dropbox or google docs and provide a link here.

I created an s3 presigned link with the zip of all the fonts on the windows machine. It’ll expire in 12 hours:

https://provider-drops.s3.us-east-1.amazonaws.com/6_fonts_new.zip?response-content-disposition=inline&X-Amz-Security-Token=IQoJb3JpZ2luX2VjELT%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaDGV1LWNlbnRyYWwtMSJGMEQCICLxDBsY8xGQTjMHp0kB03tLeJRp3IZujOQMbzLfA528AiA6QXicyk3YJUUSrvUZJeNSM6QFyeFde58M07lkjjxjPSqIAwjd%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAAaDDAwNzQ4MTU1NDY4MSIM4y8lnPzCqD3AXMvSKtwCpPk1snHHmRC21z2NmvMCE3zZmGtAzG3wAtwh8whGjAT3xigHCEQ4JlrF9Jq2hk65elDqyPQDVf%2FJ9rqjUEWZingmRc75I7Knrny8YApVEg%2FtUHB9wRofz6%2Fg%2BgOKqX14PSR1BpKUu78pyNk6Dw6ejnkA%2FvMLsGLnw5nmjPNzSQHdCLnFnqGjx%2F58uZe8W38vvlOqScLKcPUQn7dvG%2FL0jmQpJuOIY5J4vhipYKumLJdyovjzKrpJ8LDri5KO0nIPe7T53cjA8Lk5ywEVh8dSB1DHtJCeL0ZJBS%2BM9IgpaufB8Z%2FdKOSg74oCIAmIxH1hx5aE90gh1fpin7S4FnStzY7Y8543%2FiIOREVBU%2BgR6uEVDj%2FpBff%2FP7X5uA0ugf6haomgBbUcwX2ptNgCUtOvhY%2BVV4j0TuwXSbMHlxMSzryPz7Ajpx0MIxFfb%2BlIN8yiGl3MAJdkhSne5gUnMPDP6JwGOrQCfvcaN4rU11IQ8GLg0jesBVlIzymNgfZOJAJguWlsn6ncguU5zjVai3q5cvBCYWqIl6zwNSUCBe%2B35JMnSroSdYRpbKZgTe94yWIOXlW%2BsnPD9bEGFFH8IJG3CmYNjh56uLbHQla5Ikb0r1RTkv7YXyqCRvMFzWAUlfflfnN%2B1Z5XmPPzO5lkn%2BZFe2EDh9yhuc03ZTyiXzoYdtMw7HtMkRDc%2FG5L1HUUBLCCF6Oi8xOiA9IcAPeOD1StX79reCcET0VUnj%2FLYD%2B%2B0EQ4KEtS8lbxnLLlQhy9Ft9f3tuCUaI02pgEMSy2XJQl03L0jONj3y%2BaDoBK6CiziGBUgD3MfZvyD6DKbKDK0gq%2FekOANXmBDv0MB7%2Fpc7m4sIGHWzyci%2B3YM%2BHSgVou4jUxlpD6%2F8Ha2wo%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20221214T194653Z&X-Amz-SignedHeaders=host&X-Amz-Expires=43200&X-Amz-Credential=ASIAQDPPPO34VXL4NU23%2F20221214%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=15d02071320522d38a88edc541affbb040c281574a02e313c6bb46a223989139

And the fonts bundled with the service:

https://provider-drops.s3.us-east-1.amazonaws.com/bundled_fonts.zip?response-content-disposition=inline&X-Amz-Security-Token=IQoJb3JpZ2luX2VjELT%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaDGV1LWNlbnRyYWwtMSJGMEQCICLxDBsY8xGQTjMHp0kB03tLeJRp3IZujOQMbzLfA528AiA6QXicyk3YJUUSrvUZJeNSM6QFyeFde58M07lkjjxjPSqIAwjd%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAAaDDAwNzQ4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=ASIAQDPPPO34VXL4NU23%2F20221214%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=b4848440c753246fa62acd6a9d33671f7269a9b20f340727403653b23eb615b4

@ysaadi Thank you for additional information. We will check the issue with your fonts and get back to you soon.

@ysaadi Unfortunately I still cannot reproduce the problem on my side. Could you please share a test solution which reproduces the problem on your side? May be you use some non-default font settings which leads to the issue. It may be SubstitutionSettings.TableSubstitution if you assumption about 19.4 fix is correct.

We don’t touch substitutionSettings. We get the default instance and just add a font source. I can follow up with a small project that replicates this. Also, I tried to use a much smaller set of fonts that included times new roman, and the issue still reoccurred.

I can create something small and send it to you. Also, would you guys be willing to have a short meeting to discuss? The conversation here is fairly productive, but maybe having freeform discussion might be helpful at this point. the possible range of meetings where my teammates can join is about 8 am EST to 6pm EST. As an individual, I can meet at earlier times (from about 4am EST).

I’ll also check with my manager etc if I can share the full Pdf Conversion class with you. Maybe I can email it to someone? That may be helpful as well.

@ysaadi Unfortunately we do not provide support via calls/meetings. We will be waiting for the test project or conversion code from you.

Ok, here’s the class. I’ll follow up in an hour or two with a small project. let me know if anything else comes to mind.
converterclass.zip (2.6 KB)

@ysaadi Unfortunately I still cannot reproduce the problem on my side. I will try to use different environment settings and come back tomorrow.