Special character (Celsius ? )shows incorrectly in Word

Hi Team,

Japanese special character (Celsius ℃ )shows incorrectly in Word and shows as []. The PDF output is fine.

Setting font to “Cambria Math” resolves the issue. But why doesn’t is pick the right font?
Other thing I noticed is that on Word 2013 this issue is not seen.

Please find standalone code and attached documents.

Thanks,
Kumar

public static void main(String[] args) throws Exception
{
Utils.setupLicense();
Utils.printAsposeVersion();
Document doc = new Document();

DocumentBuilder docBuilder = new DocumentBuilder(doc);

// docBuilder.getFont().setName(“Cambria Math”);
docBuilder.write(“℃”);

doc.save(“C:\test_old.doc”);
doc.save(“C:\test_old.pdf”);

System.out.println(“done”);
}

Hi Kumar,

Thanks for your inquiry. DocumentBuilder.Write method inserts a string into the document at the current insert position. If you do not set the font, the default font (Times New Roman) is used. The output Docx is correct. However, Aspose.Words uses ‘Cambria Math’ font in Pdf document. I have logged this issue as WORDSNET-10741 is our issue tracking system for investigation. We will update you via this forum thread once there is any update available on this issue.

We apologize for your inconvenience.

Hi Kumar,

It is to inform you that our development
team has completed the work on the issue (WORDSNET-10741) and has come
to a conclusion that this issue and the
undesired behavior you’re observing is actually not a bug in
Aspose.Words.

Aspose.Words performs font fallback to the “Cambria Math” font because the character is not in the “Times New Roman” font. MS Word performs font fallback to “Cambria Math” too. Please try to convert output document (generated by Aspose.Words as shared in your first post) to Pdf using MS Word, you will get the same output.

Hi Tahir,

>>> Aspose.Words
performs font fallback to the “Cambria Math” font because the character
is not in the “Times New Roman” font. MS Word performs font fallback to
“Cambria Math” too.
If so, why does it still show as “Times New Roman” when the word document is opened?

>>> Please try to convert output document (generated by Aspose.Words as shared in your first post) to Pdf using MS Word, you will get the same output.
Why is the PDF generated by Aspose is good?

Additionally, select all in word and press Ctrl+Space fixes this issue.
Word 2013 version shows the character correctly.

Thanks,
Kumar

Hi Kumar,

Thanks for your inquiry.

kumaraswamy.m:

>>> Aspose.Words performs font fallback to the “Cambria Math” font because the character is not in the “Times New Roman” font.
If so, why does it still show as “Times New Roman” when the word document is opened?

In the following code example, the ‘Times New Roman’ is used as default font. This is the reason you are getting incorrect character output in Doc file. However, Pdf file shows the correct character output because the character is not in the “Times New Roman” font and Aspose.Words performs font fallback to the “Cambria Math” font.

Document doc = new Document();

DocumentBuilder docBuilder = new DocumentBuilder(doc);

// docBuilder.getFont().setName("Cambria Math");

docBuilder.write("");

doc.save("C:\\Out.doc");

doc.save("C:\\Out.pdf");

kumaraswamy.m:

>>> Please try to convert output document (generated by Aspose.Words as shared in your first post) to Pdf using MS Word, you will get the same output.
Why is the PDF generated by Aspose is good?

Please note that Aspose.Words mimics the same behaviour as MS Word does. Please check the above three steps to check this behaviour. Aspose.Words performs font fallback to the “Cambria Math” font because the character is not in the “Times New Roman” font.

Hi Tahir,

What is the solution to fix this then in Word document using Aspose Words? Set font “Cambria Math” like below?
docBuilder.getFont().setName(“Cambria
Math”);


As I had mentioned before, the character look good if the word doc is opened in Word 2013.

Thanks,
Kumar

Hi Kumar,

Thanks for your inquiry.

kumaraswamy.m:

What is the solution to fix this then in Word document using Aspose Words? Set font “Cambria Math” like below?
docBuilder.getFont().setName(“Cambria Math”);

Yes, please use ‘Cambria Math’ font to get the required output.
kumaraswamy.m:

As I had mentioned before, the character look good if the word doc is opened in Word 2013.

Yes, MS Word 2013 shows the ℃ correctly and MS Word 2010 shows the square box instead of ℃. However, MS Word 2010 and 2013 shows the ‘Times New Roman’ font. Please set the appropriate font before using such contents into the Document.