From 8fef2403bb78e7e896ecd64632788b655c7a907a Mon Sep 17 00:00:00 2001 From: Jeremy Clarke Date: Sun, 30 May 2021 01:07:53 +0100 Subject: [PATCH] Handle utf8 in tte_get_text_size --- src/tte/tte_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tte/tte_main.c b/src/tte/tte_main.c index ba1317d..33509bf 100644 --- a/src/tte/tte_main.c +++ b/src/tte/tte_main.c @@ -693,7 +693,7 @@ POINT16 tte_get_text_size(const char *str) int charW, charH= tc->font->charH; int x=0, width= 12, height= charH; - int ch; + uint ch; while( (ch= *str++) != 0 ) { @@ -721,6 +721,11 @@ POINT16 tte_get_text_size(const char *str) // --- Normal char --- default: + + // Check for UTF8 code + if(ch>=0x80) + ch= utf8_decode_char(str-1, &str); + charW= tc->font->cellW; if(x+charW > tc->marginRight) {