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

Problem with displaying Vietnamese font #3552

Open
tanmanh0707 opened this issue Nov 15, 2024 · 1 comment
Open

Problem with displaying Vietnamese font #3552

tanmanh0707 opened this issue Nov 15, 2024 · 1 comment

Comments

@tanmanh0707
Copy link

Hi Bodmer,

First of all I would like to say thanks to all of your hard word on this library.
I got problem when trying to display Vietnamese font. I used your tool Create_font.pde to create font header file.
However, the unicode character is broken on the screen.
Could you please help to check if I missed something?

Here is my code and font file, the string is "Việt Nam" and the unicode character is U1EC7:

https://github.com/humacompany/tft_espi_vietnamese_font

Thank you and best regards,
Manh

@tanmanh0707
Copy link
Author

Updated:

So I managed to draw Vietnamese characters on the screen. However, there are some curious points that I want to share with you guys and hopely I can understand them deeply.

  1. Previously, I wrongly generated *.vlw file using Processing project. I didnot specify unicode blocks area. So I tried to find what unicode block that Vietnamese font is. According to this link, it turns out that the font is listed in several noncontiguous Unicode ranges.
    Then I found an online tool to analyze font file Font Drop. The tool shows that the font is listed in 2 parts, basic latin from 0x20 to 0x7E, and Unicode characters from 0xA0 to 0xFE
    After that, I specified the Unicode blocks in Processing project in Custom range area. Finally, the *.vlw file is generated properly.

My question is, Is there a more convenient way to identify the unicode block from the font either than using above online tool?

  1. However, I cannot draw the text that is defined directly in Arduino IDE 1.8.19 using this:
String vietnamese_str = "Việt Nam";
tft.drawString(vietnamese_str, 0); //Not work - broken character

The problem is, my font file is encoded to Latin-1 and the library only support Unicode (correct me if I'm wrong)

My question is, is there a way to change decoding method to other than Unicode?

  1. Ok, so my solution is to use drawGlyph instead and it's working very very well except one thing. That is, I have to define the string as a char array instead of a string, and draw the characters one by one in a loop like this:
const char text[] = {'V', 'i', 0xD6, 't', ' ', 'N', 'a', 'm', 0x00}; //Annoying
const char *ptr = str;

while (*ptr) {
  tft.drawGlyph(*ptr);
  ptr++;
}

Also, due to draw character one by one, I need to calculate the text width manually to draw in a center alignment. I used tft.textWidth(text); but it returns incorrect width. The returned value is less than the actual printing.

Is there a way to calculate exact text width with smooth font?

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

1 participant