diff --git a/lib/TFT_eSPI/TFT_eSPI.cpp b/lib/TFT_eSPI/TFT_eSPI.cpp index 23e8fcd..be15c5a 100644 --- a/lib/TFT_eSPI/TFT_eSPI.cpp +++ b/lib/TFT_eSPI/TFT_eSPI.cpp @@ -2543,6 +2543,7 @@ void TFT_eSPI::loadFont(const uint8_t array[], uint8_t font) { gFonts[font].spaceWidth = gFonts[font].yAdvance / 4; loadMetrics(font); + fontOwned[font] = true; } void TFT_eSPI::loadMetrics(uint8_t font) @@ -4340,18 +4341,18 @@ void TFT_eSprite::drawGlyph(uint16_t code, uint16_t font) { last_cursor_x = cursor_x; } - void TFT_eSprite::copyFontFromTFT(uint8_t source, uint8_t destination) { - unloadFont(destination); // Make sure there is nothing there +void TFT_eSprite::copyFontFromTFT(uint8_t source, uint8_t destination) { + unloadFont(destination); // Make sure there is nothing there - gUnicode[destination] = _tft->gUnicode[source]; - gHeight[destination] = _tft->gHeight[source]; - gWidth[destination] = _tft->gWidth[source]; - gxAdvance[destination] = _tft->gxAdvance[source]; - gdY[destination] = _tft->gdY[source]; - gdX[destination] = _tft->gdX[source]; - gBitmap[destination] = _tft->gBitmap[source]; + gUnicode[destination] = _tft->gUnicode[source]; + gHeight[destination] = _tft->gHeight[source]; + gWidth[destination] = _tft->gWidth[source]; + gxAdvance[destination] = _tft->gxAdvance[source]; + gdY[destination] = _tft->gdY[source]; + gdX[destination] = _tft->gdX[source]; + gBitmap[destination] = _tft->gBitmap[source]; - memcpy(&gFonts[destination], &_tft->gFonts[source], sizeof(fontMetrics)); + memcpy(&gFonts[destination], &_tft->gFonts[source], sizeof(fontMetrics)); - fontOwned[destination] = false; - } \ No newline at end of file + fontOwned[destination] = false; +} \ No newline at end of file diff --git a/lib/TFT_eSPI/TFT_eSPI.h b/lib/TFT_eSPI/TFT_eSPI.h index 101c227..4d9584e 100644 --- a/lib/TFT_eSPI/TFT_eSPI.h +++ b/lib/TFT_eSPI/TFT_eSPI.h @@ -401,23 +401,17 @@ class TFT_eSPI { friend class TFT_eSprite; } fontMetrics; fontMetrics gFonts[FONT_COUNT] = { - { nullptr, 0, 0, 0, 0, 0, 0, 0 }, - { nullptr, 0, 0, 0, 0, 0, 0, 0 }, - { nullptr, 0, 0, 0, 0, 0, 0, 0 }, - { nullptr, 0, 0, 0, 0, 0, 0, 0 }, - { nullptr, 0, 0, 0, 0, 0, 0, 0 }, - { nullptr, 0, 0, 0, 0, 0, 0, 0 }, { nullptr, 0, 0, 0, 0, 0, 0, 0 } }; // These are for the metrics for each individual glyph (so we don't need to seek this in file and waste time) - uint16_t* gUnicode[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //UTF-16 code, the codes are searched so do not need to be sequential - uint8_t* gHeight[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //cheight - uint8_t* gWidth[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //cwidth - uint8_t* gxAdvance[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL}; //setWidth - int16_t* gdY[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //topExtent - int8_t* gdX[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //leftExtent - uint32_t* gBitmap[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //file pointer to greyscale bitmap + uint16_t* gUnicode[FONT_COUNT] = {NULL}; //UTF-16 code, the codes are searched so do not need to be sequential + uint8_t* gHeight[FONT_COUNT] = {NULL}; //cheight + uint8_t* gWidth[FONT_COUNT] = {NULL}; //cwidth + uint8_t* gxAdvance[FONT_COUNT] = {NULL}; //setWidth + int16_t* gdY[FONT_COUNT] = {NULL}; //topExtent + int8_t* gdX[FONT_COUNT] = {NULL}; //leftExtent + uint32_t* gBitmap[FONT_COUNT] = {NULL}; //file pointer to greyscale bitmap bool fontOwned[FONT_COUNT] = {false};