Free Support Forum -

Force font linking through code

I am currently using Aspose.Words to create a custom Microsoft Word document (in java) that needs to support various character sets but am having trouble with Font Linking.

For instance, copying the string “<span style=“font-size:10.0pt;mso-bidi-font-size:12.0pt;
font-family:“Microsoft Sans Serif”,“sans-serif”;mso-fareast-font-family:“Microsoft Sans Serif”;
mso-ansi-language:EN-US;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>ꀍ༖༗༘ث” into Word 2007 manually displays the characters correctly no matter what font you currently have set. If you look at each individual character you will see that Word figured out the current font couldn’t display the typed character and picked a font that could.

The process described in the above paragraph isn’t happening when setting the font in aspose. When you create the Word document through code and open it you will notice that all the characters are set to the font you specified even if the font can’t display that character.

Is there anyway through aspose to trigger this font linking? If not then are there any utility methods to help with manually font linking in aspose?

Hi Daniel,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word do. In your case, you just need to specify the locale so that Microsoft Word recognizes the text according to locale. I suggest you to read following documentation link.

Please check the following code examples for your kind reference and let us know if you have any more queries.

<span lang=“EN-GB” style=“font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green;mso-font-kerning:0pt;mso-fareast-language:PL”>// use of <span lang=“EN-GB” style=“font-size:10.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:green;mso-font-kerning:0pt;mso-fareast-language:PL”>getLocaleId/setLocaleId

<span lang=“EN-GB” style=“font-size:10.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:green;mso-font-kerning:0pt;
mso-fareast-language:PL”>// Create a run of text that contains Russian text.<o:p></o:p>

Run run = new Run(doc, "Привет");

// Specify the locale so Microsoft Word recognizes this text as Russian.

// For the list of locale identifiers see


// use of getLocaleIdBi/setLocaleIdBi
DocumentBuilder builder = new DocumentBuilder();

// Signal to Microsoft Word that this run of text contains right-to-left text.


// Specify the font and font size to be used for the right-to-left text.



// Specify that the right-to-left text in this run is bold and italic.



// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia.

// For the list of locale identifiers see


// Insert some Arabic text.


builder.getDocument().save(getMyDir() + "Font.Bidi Out.doc");

// use of

DocumentBuilder builder = new DocumentBuilder();


// Specify the font name. Make sure it the font has the glyphs that you want to display.


// Specify the locale so Microsoft Word recognizes this text as Chinese.

// For the list of locale identifiers see


// Insert some Chinese text.


builder.getDocument().save(getMyDir() + "Font.FarEast Out.doc");