Why Apache POI XWPFRun.setFontFamily() for cyrillic works wrong?

泄露秘密 提交于 2019-12-13 16:24:26

问题


I try to setFontFamily("Arial") to XWPFRun object with setText("Привет Hello") - cyrillic a english. English text will become Arial after this method call, but Russian text will be still at Colibri font family. How to create right font family for cyrillic text?


回答1:


Comment to setFontFamily() says:

Specifies the fonts which shall be used to display the text contents of this run. Specifies a font which shall be used to format all characters in the ASCII range (0 - 127) within the parent run

To other char try use CTFonts.setHAnsi, for example myXWPFRun.getCTR().getRPr().getRFonts().setHAnsi("Arial");

See bug https://issues.apache.org/bugzilla/show_bug.cgi?id=47148



来源:https://stackoverflow.com/questions/15196938/why-apache-poi-xwpfrun-setfontfamily-for-cyrillic-works-wrong

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!