itext XMLWorkerFontProvider.DONTLOOKFORFONTS and generate multi language HTML page

亡梦爱人 提交于 2020-01-05 04:54:07

问题


Can someone help to explain what is XMLWorkerFontProvider.DONTLOOKFORFONTS for? Not much explainations in the apidoc.

Also, I have seen some examples on XMLWorkerFontProvider.DONTLOOKFORFONTS, mostly used with XMLWorkerFontProvider.register("font file path") to generate multi language file for known text / fonts, in the case where the text is dynamic (i.e.: can be a mixture of any language ), how should this be handled? I tried to register all the google noto fonts that can support a lot of languages but the page was not rendered correctly.

This is my multi language test text:

<h4>a test |cs 测试|th ทดสอบ |j テスト|k 테스트|h מִבְחָן|a اختبار|p تست|h परीक्षण |r контрольная работа|ct 測試|a</h4>

And this is what I get in pdf: (only english)

a test |cs |th |j |k |h |a |p |h |r |ct |a

When i specified Noto Sans CJK SC font family:

<h4 style="font-family: Noto Sans CJK SC;">a test |cs 测试|th ทดสอบ |j テスト|k 테스트|h מִבְחָן|a اختبار|p تست|h परीक्षण |r контрольная работа|ct 測試|a</h4>

I get chinese, japanese, korean, russian and english:

a test |cs 测试|th |j テスト|k 테스트|h |a |p |h |r контрольная работа|ct 測試|a

When i specified Noto Sans Thai font family:

<h4 style="font-family: Noto Sans Thai;">a test |cs 测试|th ทดสอบ |j テスト|k 테스트|h מִבְחָן|a اختبار|p تست|h परीक्षण |r контрольная работа|ct 測試|a</h4>

I get Thai only:

ทดสอบ

When I specified Arial:

<h4 style="font-family: Arial;">a test |cs 测试|th ทดสอบ |j テスト|k 테스트|h מִבְחָן|a اختبار|p تست|h परीक्षण |r контрольная работа|ct 測試|a</h4>

I get english,arabic, hebrew, persian and russian only

a test |cs |th |j |k |h ןָחְבִמ |a رابتخا |p تست |h |r контрольная работа|ct |a

if I specified more than one font-family:

<h4 style="font-family: Arial, Noto Sans CJK SC, Noto Sans Thai;">a test |cs 测试|th ทดสอบ |j テスト|k 테스트|h מִבְחָן|a اختبار|p تست|h परीक्षण |r контрольная работа|ct 測試|a</h4>

the result is same as Arial case above (Is it because Arial is first font-family entry?)

a test |cs |th |j |k |h ןָחְבִמ |a رابتخا |p تست |h |r контрольная работа|ct |a

What should I do to get the right output? I am registering all the google Noto fonts with XMLHelperFontProvider.registerDirectory("").

Thanks.

来源:https://stackoverflow.com/questions/43108318/itext-xmlworkerfontprovider-dontlookforfonts-and-generate-multi-language-html-pa

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