Improve RLE font rendering

See #766
This commit is contained in:
Bodmer
2020-10-02 22:00:03 +01:00
parent ef93dbe687
commit 22ca8193c5
4 changed files with 19 additions and 15 deletions

View File

@@ -3570,8 +3570,7 @@ int16_t TFT_eSPI::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font)
inTransaction = true; inTransaction = true;
w *= height; // Now w is total number of pixels in the character w *= height; // Now w is total number of pixels in the character
if ((textsize != 1) || (textcolor == textbgcolor)) { if (textcolor == textbgcolor) {
if (textcolor != textbgcolor) fillRect(x, pY, width * textsize, textsize * height, textbgcolor);
int32_t px = 0, py = pY; // To hold character block start and end column and row values int32_t px = 0, py = pY; // To hold character block start and end column and row values
int32_t pc = 0; // Pixel count int32_t pc = 0; // Pixel count
uint8_t np = textsize * textsize; // Number of pixels in a drawn pixel uint8_t np = textsize * textsize; // Number of pixels in a drawn pixel
@@ -3618,9 +3617,9 @@ int16_t TFT_eSPI::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font)
} }
} }
else { else {
// Text colour != background && textsize = 1 and character is within screen area // Text colour != background and textsize = 1 and character is within screen area
// so use faster drawing of characters and background using block write // so use faster drawing of characters and background using block write
if ((x >= 0) && (x + width <= _width) && (y >= 0) && (y + height <= _height)) if ((textsize == 1) && (x >= 0) && (x + width <= _width) && (y >= 0) && (y + height <= _height))
{ {
setWindow(x, y, x + width - 1, y + height - 1); setWindow(x, y, x + width - 1, y + height - 1);
@@ -3640,7 +3639,8 @@ int16_t TFT_eSPI::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font)
} }
else else
{ {
int32_t px = x, py = y; // To hold character block start and end column and row values int32_t px = 0, py = 0; // To hold character pixel coords
int32_t tx = 0, ty = 0; // To hold character TFT pixel coords
int32_t pc = 0; // Pixel count int32_t pc = 0; // Pixel count
int32_t pl = 0; // Pixel line length int32_t pl = 0; // Pixel line length
uint16_t pcol = 0; // Pixel color uint16_t pcol = 0; // Pixel color
@@ -3651,21 +3651,25 @@ int16_t TFT_eSPI::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font)
if (line & 0x80) { pcol = textcolor; line &= 0x7F; } if (line & 0x80) { pcol = textcolor; line &= 0x7F; }
else pcol = textbgcolor; else pcol = textbgcolor;
line++; line++;
px = x + pc % width; px = pc % width;
py = y + pc / width; tx = x + textsize * px;
py = pc / width;
ty = y + textsize * py;
pl = 0; pl = 0;
pc += line; pc += line;
while (line--) { // In this case the while(line--) is faster while (line--) {
pl++; pl++;
if ((px+pl) >= (x + width)) { if ((px+pl) >= width) {
drawFastHLine(px, py, pl, pcol); fillRect(tx, ty, pl * textsize, textsize, pcol);
pl = 0; pl = 0;
px = x; px = 0;
tx = x;
py ++; py ++;
ty += textsize;
} }
} }
if (pl)drawFastHLine(px, py, pl, pcol); if (pl) fillRect(tx, ty, pl * textsize, textsize, pcol);
} }
} }
} }

View File

@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_ #ifndef _TFT_eSPIH_
#define _TFT_eSPIH_ #define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.2.22" #define TFT_ESPI_VERSION "2.2.23"
/*************************************************************************************** /***************************************************************************************
** Section 1: Load required header files ** Section 1: Load required header files

View File

@@ -1,6 +1,6 @@
{ {
"name": "TFT_eSPI", "name": "TFT_eSPI",
"version": "2.2.22", "version": "2.2.23",
"keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140", "keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140",
"description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32", "description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32",
"repository": "repository":

View File

@@ -1,5 +1,5 @@
name=TFT_eSPI name=TFT_eSPI
version=2.2.22 version=2.2.23
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32 sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32