From 3cd9599155aa46e4abcdfab8971e0afc27514a2b Mon Sep 17 00:00:00 2001 From: Alexander Gavrilenko Date: Thu, 9 Feb 2023 06:12:26 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=208-bit=20FSMC=20AA=20font?= =?UTF-8?q?=20colors=20(#25285)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/tft/canvas.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/tft/canvas.cpp b/Marlin/src/lcd/tft/canvas.cpp index 64cb29ade6..3fb500e8e2 100644 --- a/Marlin/src/lcd/tft/canvas.cpp +++ b/Marlin/src/lcd/tft/canvas.cpp @@ -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; @@ -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; }