Sub and super font becomes smaller when I convert word to html

The font size for the upper and lower labels of the formula in this document is 12pt.
But when I convert word to html, the font size becomes 8pt.

<span style="font-family:宋体; font-size:8pt; vertical-align:sub">4</span>

How can I solve this problem?

Document doc = new Document("/Users/zhengkai/Documents/other/33.doc");
HtmlSaveOptions nop = new HtmlSaveOptions();
nop.setEncoding(Charset.forName("UTF-8"));
nop.setExportImagesAsBase64(true);
nop.setCssStyleSheetType(CssStyleSheetType.EMBEDDED);
doc.save("/Users/zhengkai/Documents/other/33.html",nop);

33.docx (17.4 KB)

@zhengkai This is an expected behavior. In MS Word, text with Font.Subscript or Font.Superscript property set is rendered in 2/3 of its specified size. To compensate this we increase the font size specified in HTML by 3/2 upon importing HTML document and reduce font size by 2/3 upon exporting HTML.

Do you have example code or how to quickly find text with Font.Subscript or Font.Superscript and change font size

@zhengkai You can use the following code to get superscript and subscript runs:

Document doc = new Document("C:\\Temp\\in.docx");
Iterable<Run> runs = doc.getChildNodes(NodeType.RUN, true);
for(Run r : runs)
{
    if(r.getFont().getSubscript() || r.getFont().getSubscript())
    {
        // .....
    }
}