Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Chinese symbols cannot be displayed correctly #17

Open
jie326513988 opened this issue Dec 10, 2022 · 12 comments
Open

Some Chinese symbols cannot be displayed correctly #17

jie326513988 opened this issue Dec 10, 2022 · 12 comments

Comments

@jie326513988
Copy link

jie326513988 commented Dec 10, 2022

Hi, thanks for the library. It's great.
When using non isoline fonts, Chinese punctuation marks cannot be displayed correctly.
Are you still updating.
^_^

@k-omura
Copy link
Owner

k-omura commented Dec 14, 2022

Thank you for posting.
I'm doing maintenance to make all TTFs visible.
I don't fully understand non-isoline fonts. Can you tell me the name of the font that is not working? Also, if possible, could you post a picture of the failure? Thank you.

@jie326513988
Copy link
Author

I have solved this problem by replacing other fonts. I hope that the font rendering speed can be improved in the future.
On the left is abnormal display, and on the right is normal display.
On the left is 文泉驿等宽正黑.ttf On the right is 华康金刚黑极细.ttf.
未标题-1

@k-omura
Copy link
Owner

k-omura commented Dec 15, 2022

thank you for teaching me. It was nice to be able to work with other fonts for the time being.
I will try 文泉驿等宽正黑.ttf. (although it will be slow)
I recognize that it is a problem that it takes time. It takes a lot of time to fill in the inside of the characters, but I don't have any ideas for effective countermeasures. I will continue to challenge myself.

This item will be closed when the 文泉驿等宽正黑.ttf error is resolved.

@jie326513988
Copy link
Author

jie326513988 commented Dec 16, 2022

Thank you, cheer for you.
I also found that the newline character (0x0a) will cause the device to crash (esp8266).

I modified the code here, and it will work normally.

QQ截图20221217163554

@jie326513988
Copy link
Author

Hello, I optimize some places.

  1. Fix the memory leak.
  2. Fix the problem that ascii symbols will cause system crash.
  3. Add routine linked with GXEPD2, which is applicable to ink screen and esp8266.
    However, there are still some Chinese fonts that will cause the system crash. The reason is unknown.
    This is the optimized address https://github.com/jie326513988/truetype_Arduino

@k-omura
Copy link
Owner

k-omura commented Feb 11, 2023

Hello.
thank you. I was aware of the memory leak problem, but I could not fix it.
I'm also aware that some font files have some issues, but I'm working on a way to work around that.
thank you for your cooperation

@jie326513988
Copy link
Author

There is a BUG in the this->fillGlyph() function.
The reason is that the variable type of _x_min is incorrect. When the incoming parameter is a negative number, the execution time of the for loop will be very long. It should be changed to int16_t type, and the parameters of the for loop should also be modified together.

@k-omura
Copy link
Owner

k-omura commented Feb 18, 2024

Thank you for pointing out the bug. that's right.
I will fix this problem.
(I'm sorry I haven't gotten around to the original issue on this board yet.)

@jie326513988
Copy link
Author

jie326513988 commented Feb 19, 2024

Regarding the problem that result.leftSideBearing value is too large, temporarily use the modified method to solve it.
1

In the same ttf file, the values of advanceWidth and leftSideBearing parsed by some characters will be extremely large, which are obviously abnormal values. If these two values ​​can be correctly parsed, perhaps the problem of most fonts not being displayed or displaying in abnormal positions can be solved.

@jie326513988
Copy link
Author

jie326513988 commented Feb 19, 2024

When parsing the advanceWidth value and leftSideBearing value abnormally, you can use another value instead.
advanceWidth = advanceWidthMax, that is, using the advanceWidth value of special glyph index 0.
leftSideBearing = glyph.xMin.
1
2

@jie326513988
Copy link
Author

jie326513988 commented Feb 20, 2024

I found that not the first glyph of each font will provide the correct advanceWidth value, so the advanceWidth value of the first glyph cannot be used as the advanceWidthMAX value. Instead, the advanceWidth value of the English space glyph is used, and multiplied by 2 as the advanceWidthMAX value.
Together with the following modifications, most fonts can correctly display Chinese characters and punctuation marks.
5
1
2
3
4

@k-omura
Copy link
Owner

k-omura commented Feb 21, 2024

OK. Thanks for the analysis. I am currently checking locally using the TrueType code for STM32 (porting of TrueType_Arduino).
After that, it will be reflected in TrueType_Arduino as well.
Or, if you'd like, you can pullrequest your fix. Your contribution to this library is significant!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants