@@ -172,6 +172,7 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
172172 textcolor = bitmap_fg = 0xFFFF ; // White
173173 textbgcolor = bitmap_bg = 0x0000 ; // Black
174174 padX = 0 ; // No padding
175+ isDigits = false ; // No bounding box adjustment
175176 textwrapX = true ; // Wrap text at end of line when using print stream
176177 textwrapY = false ; // Wrap text at bottom of screen when using print stream
177178 textdatum = TL_DATUM; // Top Left text alignment is default
@@ -1548,7 +1549,7 @@ void TFT_eSPI::fillCircleHelper(int32_t x0, int32_t y0, int32_t r, uint8_t corne
15481549** Function name: drawEllipse
15491550** Description: Draw a ellipse outline
15501551***************************************************************************************/
1551- void TFT_eSPI::drawEllipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint16_t color)
1552+ void TFT_eSPI::drawEllipse (int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint16_t color)
15521553{
15531554 if (rx<2 ) return ;
15541555 if (ry<2 ) return ;
@@ -1603,7 +1604,7 @@ void TFT_eSPI::drawEllipse(int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint1
16031604** Function name: fillEllipse
16041605** Description: draw a filled ellipse
16051606***************************************************************************************/
1606- void TFT_eSPI::fillEllipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint16_t color)
1607+ void TFT_eSPI::fillEllipse (int16_t x0, int16_t y0, int32_t rx, int32_t ry, uint16_t color)
16071608{
16081609 if (rx<2 ) return ;
16091610 if (ry<2 ) return ;
@@ -2102,13 +2103,14 @@ int16_t TFT_eSPI::textWidth(const char *string, int font)
21022103 if (found)
21032104 {
21042105 if (str_width == 0 && gdX[gNum ] < 0 ) str_width -= gdX[gNum ];
2105- if (*string) str_width += gxAdvance[gNum ];
2106+ if (*string || isDigits ) str_width += gxAdvance[gNum ];
21062107 else str_width += (gdX[gNum ] + gWidth [gNum ]);
21072108 }
21082109 else str_width += gFont .spaceWidth + 1 ;
21092110 }
21102111 }
21112112 }
2113+ isDigits = false ;
21122114 return str_width;
21132115 }
21142116#endif
@@ -2141,8 +2143,8 @@ int16_t TFT_eSPI::textWidth(const char *string, int font)
21412143 {
21422144 uniCode -= pgm_read_byte (&gfxFont->first );
21432145 GFXglyph *glyph = &(((GFXglyph *)pgm_read_dword (&gfxFont->glyph ))[uniCode]);
2144- // If this is not the last character then use xAdvance
2145- if (*string) str_width += pgm_read_byte (&glyph->xAdvance );
2146+ // If this is not the last character or is a digit then use xAdvance
2147+ if (*string || isDigits ) str_width += pgm_read_byte (&glyph->xAdvance );
21462148 // Else use the offset plus width since this can be bigger than xAdvance
21472149 else str_width += ((int8_t )pgm_read_byte (&glyph->xOffset ) + pgm_read_byte (&glyph->width ));
21482150 }
@@ -2156,6 +2158,7 @@ int16_t TFT_eSPI::textWidth(const char *string, int font)
21562158#endif
21572159 }
21582160 }
2161+ isDigits = false ;
21592162 return str_width * textsize;
21602163}
21612164
@@ -3715,11 +3718,11 @@ size_t TFT_eSPI::write(uint8_t utf8)
37153718
37163719 // fontFile = SPIFFS.open( _gFontFilename, "r" );
37173720
3718- if (!fontFile)
3719- {
3720- fontLoaded = false ;
3721- return 0 ;
3722- }
3721+ // if(!fontFile)
3722+ // {
3723+ // fontLoaded = false;
3724+ // return 0;
3725+ // }
37233726
37243727 drawGlyph (unicode);
37253728
@@ -4147,6 +4150,7 @@ int16_t TFT_eSPI::drawString(const char *string, int poX, int poY)
41474150{
41484151 return drawString (string, poX, poY, textfont);
41494152}
4153+
41504154// With font number
41514155int16_t TFT_eSPI::drawString (const char *string, int poX, int poY, int font)
41524156{
@@ -4171,22 +4175,22 @@ int16_t TFT_eSPI::drawString(const char *string, int poX, int poY, int font)
41714175 }
41724176#endif
41734177
4174- if (textdatum || padX)
4175- {
41764178
4177- // If it is not font 1 (GLCD or free font) get the baseline and pixel height of the font
4179+ // If it is not font 1 (GLCD or free font) get the baseline and pixel height of the font
41784180#ifdef SMOOTH_FONT
4179- if (fontLoaded) {
4180- baseline = gFont .maxAscent ;
4181- cheight = fontHeight (0 );
4182- }
4183-
4184- else
4181+ if (fontLoaded) {
4182+ baseline = gFont .maxAscent ;
4183+ cheight = fontHeight ();
4184+ }
4185+ else
41854186#endif
4186- if (font!=1 ) {
4187- baseline = pgm_read_byte ( &fontdata[font].baseline ) * textsize;
4188- cheight = fontHeight (font);
4189- }
4187+ if (font!=1 ) {
4188+ baseline = pgm_read_byte ( &fontdata[font].baseline ) * textsize;
4189+ cheight = fontHeight (font);
4190+ }
4191+
4192+ if (textdatum || padX)
4193+ {
41904194
41914195 switch (textdatum) {
41924196 case TC_DATUM:
@@ -4418,13 +4422,15 @@ int16_t TFT_eSPI::drawRightString(const char *string, int dX, int poY, int font)
44184422***************************************************************************************/
44194423int16_t TFT_eSPI::drawNumber (long long_num, int poX, int poY)
44204424{
4425+ isDigits = true ; // Eliminate jiggle in monospaced fonts
44214426 char str[12 ];
44224427 ltoa (long_num, str, 10 );
44234428 return drawString (str, poX, poY, textfont);
44244429}
44254430
44264431int16_t TFT_eSPI::drawNumber (long long_num, int poX, int poY, int font)
44274432{
4433+ isDigits = true ; // Eliminate jiggle in monospaced fonts
44284434 char str[12 ];
44294435 ltoa (long_num, str, 10 );
44304436 return drawString (str, poX, poY, font);
@@ -4444,6 +4450,7 @@ int16_t TFT_eSPI::drawFloat(float floatNumber, int dp, int poX, int poY)
44444450
44454451int16_t TFT_eSPI::drawFloat (float floatNumber, int dp, int poX, int poY, int font)
44464452{
4453+ isDigits = true ;
44474454 char str[14 ]; // Array to contain decimal string
44484455 uint8_t ptr = 0 ; // Initialise pointer for array
44494456 int8_t digits = 1 ; // Count the digits to avoid array overflow
@@ -4572,7 +4579,7 @@ void TFT_eSPI::setTextFont(uint8_t f)
45724579
45734580
45744581/* **************************************************************************************
4575- ** Function name: spiBlockWrite
4582+ ** Function name: writeBlock
45764583** Description: Write a block of pixels of the same colour
45774584***************************************************************************************/
45784585// Clear screen test 76.8ms theoretical. 81.5ms TFT_eSPI, 967ms Adafruit_ILI9341
@@ -4964,6 +4971,10 @@ void TFT_eSPI::getSetup(setup_t &tft_settings)
49644971
49654972#include " Extensions/Sprite.cpp"
49664973
4974+ // #ifdef ESP32
4975+ // #include "Extensions/pSprite.cpp"
4976+ // #endif
4977+
49674978#ifdef SMOOTH_FONT
49684979 #include " Extensions/Smooth_font.cpp"
49694980#endif
0 commit comments