tomboy-notes / tomboy-ng

Next generation of Tomboy
MIT License
389 stars 38 forks source link

Cannot display chinese character in pdf export #317

Open Serenade600 opened 1 week ago

Serenade600 commented 1 week ago

The text is

测试
这里是中文
Above text is in chinese

appearing like image , but the output in pdf is like image

davidbannon commented 1 week ago

OK, so the problem there is, I am afraid, the font in use. You have not mentioned which version of tomboy-ng you are using, I recently made some improvements there but don't know if they will help you.

Please tell me which version of tomboy-ng you are using.

Maybe you can suggest what default fonts would be a good choice to support Chinese text, its a bit outside my experience ! Perhaps I should have a way for someone like you to select fonts that you know are capable of working ? Trouble is that they need to be TTF to work in the PDF exporter.

Davo

Serenade600 commented 1 week ago

I use the latest version 0.40a on windows 11. One possible choice of chinese font could be 楷体 using simkai.ttf. This font is frequently used by people and initially contained in Win system.

davidbannon commented 1 week ago

Thanks Serenade. This going to be a bit hard I am afraid. That font is not made available on English speaking versions of Windows and I don't seem to be able to download it. I generally use Linux for my development work anyway.

I suspect that Microsoft's license for simkai.tty does not allow it to embed fonts ina document the way tomboy-ng does it, just to make matters worse.

I have done some testes here and can confirm what you say, so, I have some work to do. The biggest blocker seems to be that my code requires TTF fonts, my Linux box has several Simplified Chinese capable fonts but they are not TTF. So, firstly, I need to solve that, then I should, I think, be able to allow you to set a preferred font for PDFs. That will be a good thing !

But it might just take some time I am afraid. I'd like to send you some test binaries at some stage so you can test it in a real situation. I hope you understand that I speak or write absolutely no Chinese at all, sorry !

Davo

davidbannon commented 1 week ago

OK, what I have found so far. And its not good.

I cannot get simkai.ttf, seems Microsoft does not mention it anywhere. My Windows box has several Simplified Chinese fonts preinstalled but only simsun-extB is a True Type Font. Rest are .ttc, a 'bundle' of true type in one file. And, sadly, the library I use to calculate font dimensions (fpttf) will only work with TTF.

But even with simsun-extB, that library fails to report the correct height of the font, its always 0. This problem only seems to happen with Chinese capable fonts !

I am investigating further ! Two issues, it needs to work with the more modern .ttc files and must give accurate height.

Davo

davidbannon commented 1 week ago

So, I can work around the zero height issue. Its because simsun-extB has CapHeight set to zero. That is don't understand.

But even with a workaround of the height issue, the pdf library does not reproduce the chinese characters. Using fonts know to contain the appropriate charcter. And I find reports that this is a problem elsewhere.

Not sure where this is heading but whereever it is, its going to be a slow trip !

Davo

Serenade600 commented 1 week ago

So, I can work around the zero height issue. Its because simsun-extB has CapHeight set to zero. That is don't understand.

But even with a workaround of the height issue, the pdf library does not reproduce the chinese characters. Using fonts know to contain the appropriate charcter. And I find reports that this is a problem elsewhere.

Not sure where this is heading but whereever it is, its going to be a slow trip !

Davo

Thanks for your effort. Never mind. Hitch of CJK display is often met. I could use English instead.

davidbannon commented 5 days ago

https://forum.lazarus.freepascal.org/index.php/topic,68657.msg531033