adafruit / Adafruit-GFX-Library

Adafruit GFX graphics core Arduino library, this is the 'core' class that all our other graphics libraries derive from
https://learn.adafruit.com/adafruit-gfx-graphics-library
Other
2.32k stars 1.52k forks source link

getTextBounds not working in unicode #410

Open Crapy opened 1 year ago

Crapy commented 1 year ago

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 commented 1 year ago

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