Open
Description
Advise on how to calculate the length of a string in pixels? I use this
uint16_t getStringWidth(window* _window, char* buf){
uint16_t text_width = 0;
_fontc f;
for (uint8_t i = 0; i < strlen(buf); i++){
if (0 > font_attr(_window, buf[i], &f)) {
ESP_LOGW("Text", "Char '%c' not found in the font specs!", buf[i]);
return 0;
} else {
text_width += f.skip;
}
}
return text_width;
}
but sometimes it gives poor results.
Metadata
Assignees
Labels
No labels
Activity