fix underflow in text length

This commit is contained in:
Felix Kratz 2021-12-12 15:32:16 +01:00
parent 4e2ab9b2b7
commit 13c3655da4

View file

@ -113,7 +113,8 @@ void text_clear_pointers(struct text* text) {
uint32_t text_get_length(struct text* text, bool override) {
if (!text->drawing) return 0;
if (text->has_const_width && !override) return text->custom_width;
return text->bounds.size.width + text->padding_left + text->padding_right;
int len = text->bounds.size.width + text->padding_left + text->padding_right;
return (len < 0 ? 0 : len);
}
uint32_t text_get_height(struct text* text) {