You've already forked TEF6686_ESP32
fix some font alloc stuff
This commit is contained in:
@@ -2543,6 +2543,7 @@ void TFT_eSPI::loadFont(const uint8_t array[], uint8_t font) {
|
|||||||
gFonts[font].spaceWidth = gFonts[font].yAdvance / 4;
|
gFonts[font].spaceWidth = gFonts[font].yAdvance / 4;
|
||||||
|
|
||||||
loadMetrics(font);
|
loadMetrics(font);
|
||||||
|
fontOwned[font] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFT_eSPI::loadMetrics(uint8_t font)
|
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;
|
last_cursor_x = cursor_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFT_eSprite::copyFontFromTFT(uint8_t source, uint8_t destination) {
|
void TFT_eSprite::copyFontFromTFT(uint8_t source, uint8_t destination) {
|
||||||
unloadFont(destination); // Make sure there is nothing there
|
unloadFont(destination); // Make sure there is nothing there
|
||||||
|
|
||||||
gUnicode[destination] = _tft->gUnicode[source];
|
gUnicode[destination] = _tft->gUnicode[source];
|
||||||
gHeight[destination] = _tft->gHeight[source];
|
gHeight[destination] = _tft->gHeight[source];
|
||||||
gWidth[destination] = _tft->gWidth[source];
|
gWidth[destination] = _tft->gWidth[source];
|
||||||
gxAdvance[destination] = _tft->gxAdvance[source];
|
gxAdvance[destination] = _tft->gxAdvance[source];
|
||||||
gdY[destination] = _tft->gdY[source];
|
gdY[destination] = _tft->gdY[source];
|
||||||
gdX[destination] = _tft->gdX[source];
|
gdX[destination] = _tft->gdX[source];
|
||||||
gBitmap[destination] = _tft->gBitmap[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;
|
fontOwned[destination] = false;
|
||||||
}
|
}
|
||||||
@@ -401,23 +401,17 @@ class TFT_eSPI { friend class TFT_eSprite;
|
|||||||
} fontMetrics;
|
} fontMetrics;
|
||||||
|
|
||||||
fontMetrics gFonts[FONT_COUNT] = {
|
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 }
|
{ 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)
|
// 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
|
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, NULL, NULL, NULL, NULL, NULL, NULL}; //cheight
|
uint8_t* gHeight[FONT_COUNT] = {NULL}; //cheight
|
||||||
uint8_t* gWidth[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //cwidth
|
uint8_t* gWidth[FONT_COUNT] = {NULL}; //cwidth
|
||||||
uint8_t* gxAdvance[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL}; //setWidth
|
uint8_t* gxAdvance[FONT_COUNT] = {NULL}; //setWidth
|
||||||
int16_t* gdY[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //topExtent
|
int16_t* gdY[FONT_COUNT] = {NULL}; //topExtent
|
||||||
int8_t* gdX[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //leftExtent
|
int8_t* gdX[FONT_COUNT] = {NULL}; //leftExtent
|
||||||
uint32_t* gBitmap[FONT_COUNT] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL}; //file pointer to greyscale bitmap
|
uint32_t* gBitmap[FONT_COUNT] = {NULL}; //file pointer to greyscale bitmap
|
||||||
|
|
||||||
bool fontOwned[FONT_COUNT] = {false};
|
bool fontOwned[FONT_COUNT] = {false};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user