We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

When converting Word document to HTML font selection for Asian fonts is bad

Hello Aspose support,

we are converting RTF or DOC(X) documents to HTML using Aspose Words for Java.

The code looks like this:

HtmlFixedSaveOptions options = new HtmlFixedSaveOptions();
Document doc = new Document(inputStream);
doc.save(outputStream, options);

Quite simple. This is the font setup we use:

private void setupFontsFolderWithoutDefaults(List<String> fontsFolderPaths, FontSettings fontSettings) {
    fontSettings.setFontsFolders(fontsFolderPaths.toArray(new String[fontsFolderPaths.size()]), true);

where fontsFolderPaths is a list of directories and fontSettings is FontSettings.getDefaultInstance().

A conversion problem occurs when we have Windows core fonts (like Arial or Times New Roman) in those folders as well as the NotoSansCJKjp-Regular.otf. Aspose prefers those core fonts over the NotoSans UTF-8 font which would render the results correctly (if you remove all other fonts from the configured font folders). The resulting HTML contains e.g. Times New Roman as font, while the browser uses some local font to render the characters (it realizes that Times New Roman cannot display them). But this results in text overlapping, wrong line overflows etc.

Please check out the attached screenshots of the good and bad HTML result as well as the example document (using MS Mincho for the Asian characters - but we could also have the text using a standard font replaced dynamically with some text that might contain Asian characters).
good_result.png (119.1 KB)
bad_result.png (84.4 KB)
example_document.docx (22.3 KB)

Is there any possibility to influence which fonts Aspose prefers?

Kind regards,

@stefan.raubal Yes, you can influence the font substitution process and tell Aspose.Words which font to select if some particular font is not available. Please see FontSubstitutionSettings for more information.
Also, in your case you can simply load Noto font fallback settings. Please see loadNotoFallbackSettings method for more information.

Thanks a lot @alexey.noskov for that advice!