forked from Bodmer/TFT_eSPI
Implement #896 plus minor changes
When rendering a smooth font in a sprite the anti-aliasing will pick up the sprite background colour if the text background colour is not set.
This commit is contained in:
@@ -2408,7 +2408,7 @@ void TFT_eSprite::drawGlyph(uint16_t code)
|
||||
if (newSprite)
|
||||
{
|
||||
createSprite(gWidth[gNum], gFont.yAdvance);
|
||||
if(bg) fillSprite(bg);
|
||||
if(fg != bg) fillSprite(bg);
|
||||
cursor_x = -gdX[gNum];
|
||||
cursor_y = 0;
|
||||
}
|
||||
@@ -2437,6 +2437,8 @@ void TFT_eSprite::drawGlyph(uint16_t code)
|
||||
int16_t xs = 0;
|
||||
uint16_t dl = 0;
|
||||
uint8_t pixel = 0;
|
||||
int32_t cgy = cursor_y + gFont.maxAscent - gdY[gNum];
|
||||
int32_t cgx = cursor_x + gdX[gNum];
|
||||
|
||||
for (int32_t y = 0; y < gHeight[gNum]; y++)
|
||||
{
|
||||
@@ -2459,33 +2461,35 @@ void TFT_eSprite::drawGlyph(uint16_t code)
|
||||
{
|
||||
if (pixel != 0xFF)
|
||||
{
|
||||
if (dl) { drawFastHLine( xs, y + cursor_y + gFont.maxAscent - gdY[gNum], dl, fg); dl = 0; }
|
||||
if (_bpp != 1) drawPixel(x + cursor_x + gdX[gNum], y + cursor_y + gFont.maxAscent - gdY[gNum], alphaBlend(pixel, fg, bg));
|
||||
else if (pixel>127) drawPixel(x + cursor_x + gdX[gNum], y + cursor_y + gFont.maxAscent - gdY[gNum], fg);
|
||||
if (dl) { drawFastHLine( xs, y + cgy, dl, fg); dl = 0; }
|
||||
if (_bpp != 1) {
|
||||
if (fg == bg) drawPixel(x + cgx, y + cgy, alphaBlend(pixel, fg, readPixel(x + cgx, y + cgy)));
|
||||
else drawPixel(x + cgx, y + cgy, alphaBlend(pixel, fg, bg));
|
||||
}
|
||||
else if (pixel>127) drawPixel(x + cgx, y + cgy, fg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dl==0) xs = x + cursor_x + gdX[gNum];
|
||||
if (dl==0) xs = x + cgx;
|
||||
dl++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dl) { drawFastHLine( xs, y + cursor_y + gFont.maxAscent - gdY[gNum], dl, fg); dl = 0; }
|
||||
if (dl) { drawFastHLine( xs, y + cgy, dl, fg); dl = 0; }
|
||||
}
|
||||
}
|
||||
if (dl) { drawFastHLine( xs, y + cursor_y + gFont.maxAscent - gdY[gNum], dl, fg); dl = 0; }
|
||||
if (dl) { drawFastHLine( xs, y + cgy, dl, fg); dl = 0; }
|
||||
}
|
||||
|
||||
if (pbuffer) free(pbuffer);
|
||||
|
||||
if (newSprite)
|
||||
{
|
||||
pushSprite(cursor_x + gdX[gNum], cursor_y, bg);
|
||||
pushSprite(cgx, cursor_y);
|
||||
deleteSprite();
|
||||
cursor_x += gxAdvance[gNum];
|
||||
}
|
||||
else cursor_x += gxAdvance[gNum];
|
||||
cursor_x += gxAdvance[gNum];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2503,11 +2507,7 @@ void TFT_eSprite::drawGlyph(uint16_t code)
|
||||
void TFT_eSprite::printToSprite(String string)
|
||||
{
|
||||
if(!fontLoaded) return;
|
||||
uint16_t len = string.length();
|
||||
char cbuffer[len + 1]; // Add 1 for the null
|
||||
string.toCharArray(cbuffer, len + 1); // Add 1 for the null, otherwise characters get dropped
|
||||
printToSprite(cbuffer, len);
|
||||
//printToSprite((char*)string.c_str(), string.length());
|
||||
printToSprite((char*)string.c_str(), string.length());
|
||||
}
|
||||
|
||||
|
||||
@@ -2541,7 +2541,7 @@ void TFT_eSprite::printToSprite(char *cbuffer, uint16_t len) //String string)
|
||||
|
||||
createSprite(sWidth, gFont.yAdvance);
|
||||
|
||||
if (textbgcolor != TFT_BLACK) fillSprite(textbgcolor);
|
||||
if (textcolor != textbgcolor) fillSprite(textbgcolor);
|
||||
}
|
||||
|
||||
n = 0;
|
||||
@@ -2575,7 +2575,7 @@ int16_t TFT_eSprite::printToSprite(int16_t x, int16_t y, uint16_t index)
|
||||
{
|
||||
createSprite(sWidth, gFont.yAdvance);
|
||||
|
||||
if (textbgcolor != TFT_BLACK) fillSprite(textbgcolor);
|
||||
if (textcolor != textbgcolor) fillSprite(textbgcolor);
|
||||
|
||||
drawGlyph(gUnicode[index]);
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
#ifndef _TFT_eSPIH_
|
||||
#define _TFT_eSPIH_
|
||||
|
||||
#define TFT_ESPI_VERSION "2.3.56"
|
||||
#define TFT_ESPI_VERSION "2.3.57"
|
||||
|
||||
// Bit level feature flags
|
||||
// Bit 0 set: viewport capability
|
||||
|
@@ -234,7 +234,7 @@ void loop(void)
|
||||
void printnice(int32_t v)
|
||||
{
|
||||
char str[32] = { 0 };
|
||||
sprintf(str, "%lu", v);
|
||||
sprintf(str, "%d", v);
|
||||
for (char *p = (str+strlen(str))-3; p > str; p -= 3)
|
||||
{
|
||||
memmove(p+1, p, strlen(p)+1);
|
||||
|
@@ -59,7 +59,7 @@ void loop() {
|
||||
// colour = 16 bit colour value
|
||||
// Note if rx and ry are the same then an arc of a circle is drawn
|
||||
|
||||
int fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w, unsigned int colour)
|
||||
void fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w, unsigned int colour)
|
||||
{
|
||||
|
||||
byte seg = 6; // Segments are 3 degrees wide = 120 segments for 360 degrees
|
||||
|
@@ -51,7 +51,7 @@ void loop() {
|
||||
// colour = 16 bit colour value
|
||||
// Note if rx and ry are the same an arc of a circle is drawn
|
||||
|
||||
int fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w, unsigned int colour)
|
||||
void fillArc(int x, int y, int start_angle, int seg_count, int rx, int ry, int w, unsigned int colour)
|
||||
{
|
||||
|
||||
// Make the segment size 7 degrees to prevent gaps when drawing spirals
|
||||
|
@@ -219,7 +219,7 @@ void loop(void)
|
||||
void printnice(int32_t v)
|
||||
{
|
||||
char str[32] = { 0 };
|
||||
sprintf(str, "%lu", v);
|
||||
sprintf(str, "%d", v);
|
||||
for (char *p = (str+strlen(str))-3; p > str; p -= 3)
|
||||
{
|
||||
memmove(p+1, p, strlen(p)+1);
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "TFT_eSPI",
|
||||
"version": "2.3.56",
|
||||
"version": "2.3.57",
|
||||
"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",
|
||||
"repository":
|
||||
|
@@ -1,5 +1,5 @@
|
||||
name=TFT_eSPI
|
||||
version=2.3.56
|
||||
version=2.3.57
|
||||
author=Bodmer
|
||||
maintainer=Bodmer
|
||||
sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32
|
||||
|
Reference in New Issue
Block a user