# HG changeset patch # User ideenmodellierer # Date 1589831468 -7200 # Node ID 89f6857276f82bd10bb652fbcb9251681df24f8a # Parent 3fe9cc747c5cdafe2d21116bdf661c6e3b8a5ae3 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. diff -r 3fe9cc747c5c -r 89f6857276f8 Discovery/Src/gfx_engine.c --- 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;ilength;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; diff -r 3fe9cc747c5c -r 89f6857276f8 Discovery/Src/t7.c --- a/Discovery/Src/t7.c Wed May 13 21:56:35 2020 +0200 +++ b/Discovery/Src/t7.c Mon May 18 21:51:08 2020 +0200 @@ -789,16 +789,18 @@ { text[0] = '\001'; text[1] = '\004'; - text[2] = TXT_2BYTE; - text[3] = TXT2BYTE_Sunday; - text[4] = 0; + text[2] = '\016'; + text[3] = '\016'; + text[4] = TXT_2BYTE; + text[5] = TXT2BYTE_Sunday; + text[6] = 0; if(Sdate.WeekDay != RTC_WEEKDAY_SUNDAY) - text[3] += Sdate.WeekDay; + text[5] += Sdate.WeekDay; if(!(Stime.Seconds % 2) && (dateNotSet == 1)) text[1] = '\021'; - GFX_write_string(&FontT24,&t7surfaceR,text,4); + GFX_write_string(&FontT48,&t7surfaceR,text,4); } /* DEBUG uTick Pressure and Compass */