Consolidated things as per suggestion :)
@@ -62,7 +62,7 @@ namespace blit {
const int char_size = font.char_w * height_bytes;
size_t char_off = 0;
- uint8_t fixwidth = 0;
+
for (char chr : message) {
// draw character
@@ -74,10 +74,12 @@ namespace blit {
const uint8_t* font_chr = &font.data[chr_idx * char_size];
// If this is a narrow character in fixed-width, center it in the render box
- if (!variable)
- {
- fixwidth = (font.char_w - font.char_w_variable[chr_idx]) / 2;
- c.x += fixwidth;
+ if (!variable) {
+ uint8_t fix_width = (font.char_w - font.char_w_variable[chr_idx]) / 2;
+ c.x += fix_width;
+ char_width = font.char_w - fix_width;
+ } else {
+ char_width = font.char_w_variable[chr_idx];
}
for (uint8_t y = 0; y < font.char_h; y++) {
@@ -97,11 +99,6 @@ namespace blit {
}
}
- if (!variable)
- char_width = font.char_w - fixwidth;
- else
- char_width = font.char_w_variable[chr_idx];
-
// increment the cursor
c.x += char_width;
if (chr == 10) {
