Skip to content

Commit

Permalink
🐛 Fix 8-bit FSMC AA font colors (MarlinFirmware#25285)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmz52 authored and thinkyhead committed Feb 21, 2023
1 parent 6e9c5f9 commit a4d5887
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Marlin/src/lcd/tft/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ void CANVAS::AddText(uint16_t x, uint16_t y, uint16_t color, uint16_t *string, u

uint16_t colors[16];
uint16_t stringWidth = 0;
if (GetFontType() == FONT_MARLIN_GLYPHS_2BPP) {
for (uint8_t i = 0; i < 3; i++) {
colors[i] = gradient(ENDIAN_COLOR(color), ENDIAN_COLOR(background_color), ((i+1) << 8) / 3);
colors[i] = ENDIAN_COLOR(colors[i]);
}
}
for (uint16_t i = 0 ; *(string + i) ; i++) {
glyph_t *glyph = Glyph(string + i);
if (stringWidth + glyph->BBXWidth > maxWidth) break;
Expand All @@ -82,8 +88,6 @@ void CANVAS::AddText(uint16_t x, uint16_t y, uint16_t color, uint16_t *string, u
AddImage(x + stringWidth + glyph->BBXOffsetX, y + GetFontAscent() - glyph->BBXHeight - glyph->BBXOffsetY, glyph->BBXWidth, glyph->BBXHeight, GREYSCALE1, ((uint8_t *)glyph) + sizeof(glyph_t), &color);
break;
case FONT_MARLIN_GLYPHS_2BPP:
for (uint8_t i = 0; i < 3; i++)
colors[i] = gradient(color, background_color, ((i+1) << 8) / 3);
AddImage(x + stringWidth + glyph->BBXOffsetX, y + GetFontAscent() - glyph->BBXHeight - glyph->BBXOffsetY, glyph->BBXWidth, glyph->BBXHeight, GREYSCALE2, ((uint8_t *)glyph) + sizeof(glyph_t), colors);
break;
}
Expand Down

0 comments on commit a4d5887

Please sign in to comment.