Mercurial > public > ostc4
diff Discovery/Src/gfx_engine.c @ 481:89f6857276f8 Improve_Button_Sleep
Bugfix calculation of string center position:
Strings shown on the right side at surface mode use special characters ('\016' and '\017') to switch font size. Headline strings like "Desaturation" could also be set to the target font directly, because they do not contain mixed font sizes, but nethertheless they are using the special characters.
The function calculating the offset needed to display the strinter with center alignment did not consider the small font size => misalignment during string display. To avoid this an evaluation of the special characters has been added to the helper function.
author | ideenmodellierer |
---|---|
date | Mon, 18 May 2020 21:51:08 +0200 |
parents | e141b571a03d |
children | 7a17bfc932b6 |
line wrap: on
line diff
--- a/Discovery/Src/gfx_engine.c Wed May 13 21:56:35 2020 +0200 +++ b/Discovery/Src/gfx_engine.c Mon May 18 21:51:08 2020 +0200 @@ -3085,6 +3085,8 @@ uint8_t gfx_selected_language; uint32_t pText; uint16_t decodeUTF8; + uint8_t tinyState = 0; /* used to identify the usage of tiny font */ + tFont* ptargetFont; #ifndef BOOTLOADER_STANDALONE SSettings *pSettings; @@ -3102,6 +3104,22 @@ j = 0; while (*(char*)pText != 0)// und fehlend: Abfrage window / image size { + if(*(char*)pText == '\016') /* request font change */ + { + tinyState++; + } + if(*(char*)pText == '\017') /* request font reset */ + { + tinyState = 0; + } + if(tinyState > 1) + { + ptargetFont = (tFont *)cfg->TinyFont; + } + else + { + ptargetFont = (tFont *)cfg->font; + } if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */ { decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */ @@ -3113,20 +3131,20 @@ decodeUTF8 = *(char*)pText; /* place ASCII char */ } - for(i=0;i<((tFont *)cfg->font)->length;i++) + for(i=0;i<ptargetFont->length;i++) { - if(((tFont *)cfg->font)->chars[i].code == decodeUTF8) + if(ptargetFont->chars[i].code == decodeUTF8) { - Xsum += ((tFont *)cfg->font)->chars[i].image->width; + Xsum += ptargetFont->chars[i].image->width; break; } } pText++; j++; - if(((tFont *)cfg->font == &FontT144) && (*(char*)pText != 0)) + if((ptargetFont == &FontT144) && (*(char*)pText != 0)) Xsum += 3; else - if(((tFont *)cfg->font == &FontT105) && (*(char*)pText != 0)) + if((ptargetFont == &FontT105) && (*(char*)pText != 0)) Xsum += 2; } pText -= j;