phax / ph-pdf-layout

Java library for creating fluid page layouts with Apache PDFBox. Supporting multi-page tables, different page layouts etc.
Apache License 2.0
64 stars 11 forks source link

How to correct display Chinese? #19

Closed KenteJohn closed 4 years ago

KenteJohn commented 4 years ago

I get some "?" characters when I write a sentense in Chinese. I have tried almost all the fonts, but it didn't work. I hope to get your response as soon as possible,thank you.

phax commented 4 years ago

Hi, try selecting a font at https://fonts.google.com/?subset=chinese-simplified - that should give you a quite broad range.

If you find something suitable, I may be able to add it to https://github.com/phax/ph-fonts to have it available in a more suitable way.

hth

KenteJohn commented 4 years ago

Thank you for your help, but due to some policy reasons, I can't visit google.com in China. Everything in your project fits me but fonts, I need Chinese support very much and don't want to give it up.

KenteJohn commented 4 years ago

Maybe 'Noto Sans HK' can work?

phax commented 4 years ago

Hi. It only has "Noto Sans SC": grafik

If you like, you can paste an example text here and I send you the screenshot.

phax commented 4 years ago

My bad. I also found the "Noto Sans HK"

phax commented 4 years ago

Glyphs of Noto Sans HK: grafik

Is that what you are looking for?

KenteJohn commented 4 years ago

Wow, 'Noto Sans SC' is ok.

phax commented 4 years ago

Just for comparison, these are the glyphs of "Noto Sans SC": grafik

KenteJohn commented 4 years ago

HK is complex font, SC is simplified font. I want the simplified font.

KenteJohn commented 4 years ago

Maybe 'SC' is simplified Chinese, I guess.

phax commented 4 years ago

Yes exactly. There is also a version "TC" for "Traditional Chinese"

KenteJohn commented 4 years ago

So, I can use this font at some point in the future, maybe after a few days or months?

phax commented 4 years ago

Yes, I am just trying it out in https://github.com/phax/ph-fonts - if it works, I will release 4.1.2 and create an example in here.

Is this is a reasonable test text:

他们所有的设备和仪器彷佛都是有生命的。

???

KenteJohn commented 4 years ago

Yes and thank you for your support.

phax commented 4 years ago

Unfortunately it doesn't work. pdfbox has problems with the OTF font. Any conversion tool from OTF to TTF I tried so far failed :(

KenteJohn commented 4 years ago

I believe you can resolve this problem. 加油!

phax commented 4 years ago

So I found a solution. Please see the attached PDF examples. Do they look good for you?

font-noto-sans-hk.pdf font-noto-sans-sc.pdf

KenteJohn commented 4 years ago

I can not see them. The hyperlinks are invalid. Could you give me the directory path about your output?

KenteJohn commented 4 years ago

oh, I get the path: pdf/pltext/font-noto-sans-sc.pdf. Thank you.