Skip to content

Commit

Permalink
Avoid warnings if fonts disabled in setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodmer committed May 19, 2022
1 parent bed6595 commit ba81976
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
26 changes: 22 additions & 4 deletions Extensions/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2076,15 +2076,16 @@ void TFT_eSprite::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uin

uint8_t w = pgm_read_byte(&glyph->width),
h = pgm_read_byte(&glyph->height);
int8_t xo = pgm_read_byte(&glyph->xOffset),
yo = pgm_read_byte(&glyph->yOffset);

if (((x + w * size - 1) < (_vpX - _xDatum)) || // Clip left
((y + h * size - 1) < (_vpY - _yDatum))) // Clip top
if (((x + xo + w * size - 1) < (_vpX - _xDatum)) || // Clip left
((y + yo + h * size - 1) < (_vpY - _yDatum))) // Clip top
return;

uint8_t *bitmap = (uint8_t *)pgm_read_dword(&gfxFont->bitmap);
uint32_t bo = pgm_read_word(&glyph->bitmapOffset);
int8_t xo = pgm_read_byte(&glyph->xOffset),
yo = pgm_read_byte(&glyph->yOffset);

uint8_t xx, yy, bits=0, bit=0;
//uint8_t xa = pgm_read_byte(&glyph->xAdvance);
int16_t xo16 = 0, yo16 = 0;
Expand Down Expand Up @@ -2126,6 +2127,12 @@ void TFT_eSprite::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uin
#ifdef LOAD_GFXFF
} // End classic vs custom font
#endif
#else
#ifndef LOAD_GFXFF
color = color;
bg = bg;
size = size;
#endif
#endif

}
Expand Down Expand Up @@ -2385,6 +2392,17 @@ int16_t TFT_eSprite::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t fo
}
// End of RLE font rendering
#endif

#if !defined (LOAD_FONT2) && !defined (LOAD_RLE)
// Stop warnings
flash_address = flash_address;
w = w;
pX = pX;
pY = pY;
line = line;
clip = clip;
#endif

return width * textsize; // x +
}

Expand Down
28 changes: 24 additions & 4 deletions TFT_eSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ TFT_eSPI::TFT_eSPI(int16_t w, int16_t h)
_cp437 = true; // Legacy GLCD font bug fix
_utf8 = true; // UTF8 decoding enabled

#ifdef FONT_FS_AVAILABLE
#if defined (FONT_FS_AVAILABLE) && defined (SMOOTH_FONT)
fs_font = true; // Smooth font filing system or array (fs_font = false) flag
#endif

Expand Down Expand Up @@ -3016,9 +3016,6 @@ void TFT_eSPI::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32
{
if (_vpOoB) return;

int32_t xd = x + _xDatum;
int32_t yd = y + _yDatum;

if (c < 32) return;
#ifdef LOAD_GLCD
//>>>>>>>>>>>>>>>>>>
Expand All @@ -3027,6 +3024,9 @@ void TFT_eSPI::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32
#endif
//>>>>>>>>>>>>>>>>>>

int32_t xd = x + _xDatum;
int32_t yd = y + _yDatum;

if ((xd >= _vpW) || // Clip right
( yd >= _vpH) || // Clip bottom
((xd + 6 * size - 1) < _vpX) || // Clip left
Expand Down Expand Up @@ -3153,6 +3153,15 @@ void TFT_eSPI::drawChar(int32_t x, int32_t y, uint16_t c, uint32_t color, uint32
#ifdef LOAD_GFXFF
} // End classic vs custom font
#endif
#else
#ifndef LOAD_GFXFF
// Avoid warnings if fonts are disabled
x = x;
y = y;
color = color;
bg = bg;
size = size;
#endif
#endif

}
Expand Down Expand Up @@ -4863,6 +4872,17 @@ int16_t TFT_eSPI::drawChar(uint16_t uniCode, int32_t x, int32_t y, uint8_t font)
}
// End of RLE font rendering
#endif

#if !defined (LOAD_FONT2) && !defined (LOAD_RLE)
// Stop warnings
flash_address = flash_address;
w = w;
pX = pX;
pY = pY;
line = line;
clip = clip;
#endif

return width * textsize; // x +
}

Expand Down

0 comments on commit ba81976

Please sign in to comment.