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

getTextBounds not working in unicode #410

Open
Crapy opened this issue Dec 10, 2022 · 1 comment
Open

getTextBounds not working in unicode #410

Crapy opened this issue Dec 10, 2022 · 1 comment

Comments

@Crapy
Copy link

Crapy commented Dec 10, 2022

So I am using thre standard Arduino library as well as gfx to display text in an e ink display, I have used a custom arial font and cannot figure out how to align a text to the right so the start of the text is all on the same exact horizontal line, since I am using an RTL language it will look better that way

i tried to use getTextBounds but it doesn't appear to correctly calculate the width


uint16_t w, h;

display.getTextBounds(string, 0, 0, &x1, &y1, &w, &h);

uint16_t fullx = x - w;

display.setCursor(fullx, 10);

It does work when using a string that only contains English but not unicode language (Hebrew)

Any idea what am I doing wrong? Or is it a problem with char byte calculation?

@PaintYourDragon
Copy link
Contributor

Unfortunately only 7- to 8-bit charsets are supported, as GFX needs to run on small devices going back to AVR (e.g. Arduino Uno).

There are some good alternatives if you’re using a 32-bit microcontroller, have a look at LovyanGFX and LVGL. The former is based somewhat on Adafruit_GFX so it might be an easier transition. Latter can produce really polished UIs but you’d be starting fresh.
https://github.com/lovyan03/LovyanGFX
https://lvgl.io

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