MCPcopy Create free account
hub / github.com/Blueforcer/awtrix3 / getTextWidth

Function getTextWidth

src/Functions.cpp:99–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99float getTextWidth(const char *text, byte textCase)
100{
101 float width = 0;
102 for (const char *c = text; *c != '\0'; ++c)
103 {
104 char current_char = *c;
105 if ((UPPERCASE_LETTERS && textCase == 0) || textCase == 1)
106 {
107 current_char = toupper(current_char);
108 }
109 if (CharMap.count(current_char) > 0)
110 {
111 width += CharMap[current_char];
112 }
113 else
114 {
115 if (current_char == 0x83 ||
116 current_char == 0x85 ||
117 current_char == 0x8B ||
118 current_char == 0x93 ||
119 current_char == 0x97 ||
120 current_char == 0x9A ||
121 current_char == 0x9D)
122 {
123 width += 6;
124 }
125 else if (current_char == 0x98)
126 {
127 width += 7;
128 }
129 else if (current_char == 0x99 ||
130 current_char == 0x95 ||
131 current_char == 0x87 ||
132 current_char == 0x88)
133 {
134 width += 5;
135 }
136 else
137 {
138 width += 4;
139 }
140 }
141 // Serial.printf("Zeichen: %c, ASCII-Wert: %d\n", current_char, static_cast<int>(current_char));
142 }
143 return width;
144}
145
146static byte c1;
147byte utf8ascii(byte ascii)

Callers 5

NotifyOverlayFunction · 0.85
printTextMethod · 0.85
HSVtextMethod · 0.85
GradientTextMethod · 0.85
ShowCustomAppFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected