Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodmer committed Dec 12, 2021
1 parent bcce0fc commit a474f4c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Extensions/Sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2529,19 +2529,24 @@ void TFT_eSprite::printToSprite(char *cbuffer, uint16_t len) //String string)

uint16_t n = 0;
bool newSprite = !_created;
int16_t cursorX = _tft->cursor_x;

if (newSprite)
{
int16_t sWidth = 1;
int16_t sWidth = 0;
uint16_t index = 0;

bool first = true;
while (n < len)
{
uint16_t unicode = decodeUTF8((uint8_t*)cbuffer, &n, len - n);
if (getUnicodeIndex(unicode, &index))
{
if (n == 0) sWidth -= gdX[index];
if (n == len-1) sWidth += ( gWidth[index] + gdX[index]);
if (first) {
first = false;
sWidth -= gdX[index];
cursorX += gdX[index];
}
if (n == len) sWidth += ( gWidth[index] + gdX[index]);
else sWidth += gxAdvance[index];
}
else sWidth += gFont.spaceWidth + 1;
Expand All @@ -2564,7 +2569,7 @@ void TFT_eSprite::printToSprite(char *cbuffer, uint16_t len) //String string)

if (newSprite)
{ // The sprite had to be created so place at TFT cursor
pushSprite(_tft->cursor_x, _tft->cursor_y);
pushSprite(cursorX, _tft->cursor_y);
deleteSprite();
}
}
Expand Down

0 comments on commit a474f4c

Please sign in to comment.