Formula translation on different machines

Hello.
I’m using aspose on different environment. One for testing and one on production. For some reason I’m testing on Unix and my production is on windows.
In order to make everything work fine, I have a special folder where I have exactly the same fonts. I’m using FontSettings.setFontFolders to give the right font folders.
I’m also using FallbackSettings().loadNotoFallbackSettings()

On unix, it works, but on windows, when I give the attached word file, the formula is not well translated. (see the attached files)

asposeTopicFormula.zip (60.9 KB)

@rodrigue.leopold Could you please attach your outputs produced in Unix and windows environments? As I can see equation is rendered fine in Windows on my side.

Please note that MS Word uses Cambria Math font for rendering OfficeMath, the same does Aspose.Words. If this font is not available, the equation rendering result might differ from the one shown in MS Word.

Hello.
For windows I already sent you the output. There is a little square in the formula (a missing “d”).
Here is the unix output

asposeTopicFormula.zip (83.1 KB)

@rodrigue.leopold Thank you for additional information. Unfortunately, I cannot reproduce the problem on my side.
Could you please convert the attached simplified document to PDF and XPS in your environments and attach the produced output here for our reference?
in.docx (33.9 KB)
Is the problem reproducible on your side upon saving to PDF and XPS?

Hello.
No the problem is not reproductible. The PDF seems OK.
OK. I’ve opened a remote desktop to the production windows machine. I opened the in.docx with word and exported the document to PDF and XPS

in.zip (250.0 KB)

To make it, as easy as possible, I’ve created this simple test case.
You have to know that I also tried to use a shared font folder, to make sur that every fonts are available. It didn’t work.

If you need more input, I can execute this test on the machine with any hint or log you want.
The test, transforms the word into an HTML file. If you want I can share with you (with weTransfer for example) the windows Font folder.

test-aspose.zip (113.4 KB)

@rodrigue.leopold Thank you for additional information. But I meant convert the document to PDF and XPS using Aspose.Words in both of your environments.

Document doc = new Document("C:\\Temp\\in.docx");
doc.save("C:\\Temp\\out.xps");
doc.save("C:\\Temp\\out.pdf");

This will allow to see the difference in the fonts used for document rendering.

YES… This time, I’ve got the data.

Here is the code I executed. I load the doc, and save it three times : 1 the PDF, 2 the XPS, 3 the HTML.
The 2 first work and the HTML fails.

test-aspose.zip (650.5 KB)

@rodrigue.leopold Thank you for additional information. Could you please attach Cambria Math, Verdana and Arial fonts from the prod Windows environment where the problem occurs?

Here are the fonts, on the machine. But, as I told you, I also tried to use shared fonts, on another directory with FontSettings.setFontFolders and FallbackSettings().loadNotoFallbackSettings(). But it didn’t work…

It seems that one cambria file is in double. It’s the CAMBRIA_5.TTC and the CAMBRIA.TTC. I compared the file with the “diff” tool and both files are identical.

Here are the font installed in the defaut C:/Windows/Fonts folder.

fonts.zip (5.4 MB)

@rodrigue.leopold It is really strange. Unfortunately, I still cannot reproduce the problem on my side. I have used the following simple code for testing:

FontSettings.getDefaultInstance().setFontsSources(new FontSourceBase[] { new FolderFontSource("C:\\Temp\\fonts", true) });
        
Document doc = new Document("C:\\Temp\\in.docx");
doc.save("C:\\Temp\\out.html");

C:\Temp\fonts contains the fonts you have attached. Could you please try with the same code on your side?

You are using Windows fonts, so there is no need to use Noto Fallback Settings.

I don’t know, I had a lot of problems making everything work on UNIX and on windows. I must have seen this instruction on a forum somewhere and I tried it. Is it a problem ?

I will try. Is it possible, that aspose uses a driver installed on the windows machine ? If true, is it possible to disable this feature and ask aspose to not use the local windows driver ?

Hello.

I tried, but it’s still the same. The little “d” is not translated.

I also tried with only the arial fonts in the directory. When I do so, the formula is totally translated (I’ve attached the result) This proves, that the font folder is taken into account.

out.001.png (2.5 KB)

QUESTION : Is it possible, that aspose uses a driver, on the windows machine. A driver that has expired and is not supported anymore ?

@rodrigue.leopold

Unfortunately, I cannot say what the reason of the problem is, since I cannot reproduce it on my side.

It is not quite clear what you mean. Actually the problem is really strange, because on the same image d in one place is rendered properly, but in another it is rendered as a missed character. internal representation is also the same:

<m:sub>
	<m:r>
		<w:rPr>
			<w:rFonts w:ascii="Cambria Math"/>
			<w:sz w:val="18"/>
			<w:szCs w:val="18"/>
		</w:rPr>
		<m:t>yd</m:t>
	</m:r>
</m:sub>

and

<m:sub>
	<m:r>
		<w:rPr>
			<w:rFonts w:ascii="Cambria Math"/>
			<w:sz w:val="18"/>
			<w:szCs w:val="18"/>
		</w:rPr>
		<m:t>cd</m:t>
	</m:r>
</m:sub>

As you can see yd and cd are represented the same, but for some reason yd on your side is rendered improperly.

OK. But what’s the next step ? How to solve the problem ? Can I activate some logging to help you find the bug ? Do you want me to execute somethnig on the machine to help you find the problem.

You uglify the code so it’s impossible to debug it. What can we do ?

@rodrigue.leopold Could you please try rendering the formula separately from the document using the following code:

Document doc = new Document("C:\\temp\\in.docx");
doc.setWarningCallback(new WarningCollector());
        
OfficeMath math = (OfficeMath)doc.getChild(NodeType.OFFICE_MATH, 0, true);
math.getMathRenderer().save("C:\\Temp\\out.png", new ImageSaveOptions(SaveFormat.PNG));
private static class FontSubstitutionWarningCollector implements IWarningCallback {

    public void warning(WarningInfo info) {
        System.out.println(info.getDescription());
    }
}

Does the code show some warnings? Does the output image has the problem?

Hello,
I’ve tried your code, and there are no warning in the output.

But I have a hint for you. The problem is not the "d" but the "y".
Here is what I did. I opened the word as a zip file and modified the "<m:t>yd</m:t>".
If I write "ye" or "yde", every letters after the "y" is replaced by a little square.
I also tried "ydyde" and "aydyde". (here is the result)

out_aydyde.png (1.3 KB)

out_ydyde.png (1.3 KB)

If you look carefully at the ydyde picture, there is a little black dot at the top of the last square, as if the square was hiding something behind itself.

I also tried to put, the "y" in a <m:r> block, and the "d" in a second <m:r> block, and it works. The d is well translated.

@rodrigue.leopold Thank you for additional information. I will consult with my colleagues and provide you more information.

@rodrigue.leopold I have consulted with my colleagues, but unfortunately, there are no clues why this might occur on your side. We have tested the scenario on different machines, but the problem is still not reproducible.
As I can see you are using an old 21.5 version of Aspose.Words for Java. I can suggest you to try using the latest 24.3 version and see whether this will make any difference in the formula rendering.

Hello,
It didn’t work. I even tried to use another JRE (Oracle and Adoptium)
I also tried to install JAI. But it didn’t change anything.