diff Discovery/Src/gfx_engine.c @ 567:1c95f811967c

-Add 12HR Time Support -Add firmware image only font extensions -Show english units when required in log's graphs -Show decompression info with Font84 if 10 characters long -Remove usage of ' symbol to denote minutes and instead use min abbreviation -Show english units when required on the simulation configuration screen -Remove usage of ' symbol to denote feet in in non-metric mode and use ft abbrevation
author izzni
date Tue, 24 Nov 2020 13:22:23 -0600
parents 7b56d4eda695
children 3860b8fa4b29
line wrap: on
line diff
--- a/Discovery/Src/gfx_engine.c	Sat Nov 21 17:41:59 2020 +0100
+++ b/Discovery/Src/gfx_engine.c	Tue Nov 24 13:22:23 2020 -0600
@@ -2656,6 +2656,7 @@
 
 static uint32_t GFX_write_char(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font)
 {
+	Font = GFX_Check_Extra_Font(character, Font);
 	if(cfg->doubleSize)
 	{
 		return GFX_write_char_doubleSize(hgfx, cfg, character, Font);
@@ -3138,14 +3139,8 @@
 			decodeUTF8 = *(char*)pText; /* place ASCII char */
 		}
 
-		for(i=0;i<ptargetFont->length;i++)
-		{
-			if(ptargetFont->chars[i].code == decodeUTF8)
-			{
-				Xsum += ptargetFont->chars[i].image->width;
-				break;
-			}
-		}
+		Xsum += GFX_Character_Width(decodeUTF8, ptargetFont);
+
 		pText++;
 		j++;
 		if((ptargetFont == &FontT144) && (*(char*)pText != 0))
@@ -3248,14 +3243,7 @@
 			{
 				decodeUTF8 = *(char*)pText;
 			}
-			for(i=0;i<font->length;i++)						/* lookup character and add width */
-			{
-				if(font->chars[i].code == decodeUTF8)
-				{
-					Xsum += font->chars[i].image->width;
-					break;
-				}
-			}
+			Xsum += GFX_Character_Width(decodeUTF8, font);  /* lookup character and add width */
 		}
 		pText++;
 		j++;
@@ -3873,3 +3861,77 @@
 	}
 */	
 }
+
+tFont* GFX_Check_Extra_Font(uint8_t character, tFont *Font)
+{
+	uint32_t i;
+	uint32_t found;
+
+	found = 0;
+	for(i=0;i<Font->length;i++)
+	{
+		if(Font->chars[i].code == character)
+		{
+			found = 1;
+			break;
+		}
+	}
+	if (!found && Font == &FontT54)
+	{
+		Font = &FontT54Extra;
+	}
+	else if (!found && (Font == &FontT84 || Font == &FontT84Spaced))
+	{
+		Font = &FontT84Extra;
+	}
+	else if (!found && Font == &FontT105)
+	{
+		Font = &FontT105Extra;
+	}
+
+	return Font;
+}
+
+uint32_t GFX_Character_Width(uint8_t character, tFont *Font)
+{
+	uint32_t i;
+	uint32_t found;
+
+	for(i=0;i<Font->length;i++)
+	{
+		if(Font->chars[i].code == character)
+		{
+			return Font->chars[i].image->width;
+		}
+	}
+
+	found = 0;
+	if (Font == &FontT54)
+	{
+		found = 1;
+		Font = &FontT54Extra;
+	}
+	else if (Font == &FontT84 || Font == &FontT84Spaced)
+	{
+		found = 1;
+		Font = &FontT84Extra;
+	}
+	else if (Font == &FontT105)
+	{
+		found = 1;
+		Font = &FontT105Extra;
+	}
+
+	if (found)
+	{
+		for(i=0;i<Font->length;i++)
+		{
+			if(Font->chars[i].code == character)
+			{
+				return Font->chars[i].image->width;
+			}
+		}
+	}
+
+	return 0;
+}