[FreeTypeGX] Fix using the corrent font size when caching the glyhData

This commit is contained in:
Maschell 2020-08-16 11:58:01 +02:00
parent 858688704b
commit b00fa46da6

View File

@ -173,7 +173,6 @@ void FreeTypeGX::unloadFont() {
ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize) { ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize) {
fontDataMutex.lock(); fontDataMutex.lock();
auto itr = fontData.find(pixelSize); auto itr = fontData.find(pixelSize);
bool updateAlign = false;
if (itr != fontData.end()) { if (itr != fontData.end()) {
auto itr2 = itr->second.ftgxCharMap.find(charCode); auto itr2 = itr->second.ftgxCharMap.find(charCode);
if (itr2 != itr->second.ftgxCharMap.end()) { if (itr2 != itr->second.ftgxCharMap.end()) {
@ -181,20 +180,16 @@ ftgxCharData *FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize) {
fontDataMutex.unlock(); fontDataMutex.unlock();
return &itr2->second; return &itr2->second;
} }
} else {
updateAlign = true;
} }
ftGX2Data *ftData = &fontData[pixelSize]; ftGX2Data *ftData = &fontData[pixelSize];
faceMutex.lock(); faceMutex.lock();
if (updateAlign) { FT_Set_Pixel_Sizes(ftFace, 0, pixelSize);
FT_Set_Pixel_Sizes(ftFace, 0, pixelSize);
ftData->ftgxAlign.ascender = (int16_t) ftFace->size->metrics.ascender >> 6; ftData->ftgxAlign.ascender = (int16_t) ftFace->size->metrics.ascender >> 6;
ftData->ftgxAlign.descender = (int16_t) ftFace->size->metrics.descender >> 6; ftData->ftgxAlign.descender = (int16_t) ftFace->size->metrics.descender >> 6;
}
FT_UInt gIndex; FT_UInt gIndex;
uint16_t textureWidth = 0, textureHeight = 0; uint16_t textureWidth = 0, textureHeight = 0;