Skip to content

Commit 61079d6

Browse files
jmz52thinkyhead
authored andcommitted
🐛 Fix 8-bit FSMC AA font colors (#25285)
1 parent c1b490c commit 61079d6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Marlin/src/lcd/tft/canvas.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ void CANVAS::AddText(uint16_t x, uint16_t y, uint16_t color, uint16_t *string, u
7474

7575
uint16_t colors[16];
7676
uint16_t stringWidth = 0;
77+
if (GetFontType() == FONT_MARLIN_GLYPHS_2BPP) {
78+
for (uint8_t i = 0; i < 3; i++) {
79+
colors[i] = gradient(ENDIAN_COLOR(color), ENDIAN_COLOR(background_color), ((i+1) << 8) / 3);
80+
colors[i] = ENDIAN_COLOR(colors[i]);
81+
}
82+
}
7783
for (uint16_t i = 0 ; *(string + i) ; i++) {
7884
glyph_t *glyph = Glyph(string + i);
7985
if (stringWidth + glyph->BBXWidth > maxWidth) break;
@@ -82,8 +88,6 @@ void CANVAS::AddText(uint16_t x, uint16_t y, uint16_t color, uint16_t *string, u
8288
AddImage(x + stringWidth + glyph->BBXOffsetX, y + GetFontAscent() - glyph->BBXHeight - glyph->BBXOffsetY, glyph->BBXWidth, glyph->BBXHeight, GREYSCALE1, ((uint8_t *)glyph) + sizeof(glyph_t), &color);
8389
break;
8490
case FONT_MARLIN_GLYPHS_2BPP:
85-
for (uint8_t i = 0; i < 3; i++)
86-
colors[i] = gradient(color, background_color, ((i+1) << 8) / 3);
8791
AddImage(x + stringWidth + glyph->BBXOffsetX, y + GetFontAscent() - glyph->BBXHeight - glyph->BBXOffsetY, glyph->BBXWidth, glyph->BBXHeight, GREYSCALE2, ((uint8_t *)glyph) + sizeof(glyph_t), colors);
8892
break;
8993
}

0 commit comments

Comments
 (0)