Calucate the textWidth by using the CharWidth method in FreeTypeGX

This commit is contained in:
Maschell 2020-08-13 14:14:26 +02:00
parent 92cd5c34fc
commit 6f91796cfc
1 changed files with 1 additions and 12 deletions

View File

@ -396,20 +396,9 @@ uint16_t FreeTypeGX::getWidth(const wchar_t *text, int16_t pixelSize) {
if (!text) { return 0; }
uint16_t strWidth = 0;
FT_Vector pairDelta;
int32_t i = 0;
while (text[i]) {
ftgxCharData *glyphData = cacheGlyphData(text[i], pixelSize);
if (glyphData != NULL) {
if (ftKerningEnabled && (i > 0)) {
FT_Get_Kerning(ftFace, fontData[pixelSize].ftgxCharMap[text[i - 1]].glyphIndex, glyphData->glyphIndex, FT_KERNING_DEFAULT, &pairDelta);
strWidth += pairDelta.x >> 6;
}
strWidth += glyphData->glyphAdvanceX;
}
strWidth += getCharWidth(text[i], pixelSize, i > 0 ? text[i - 1] : 0);
++i;
}
return strWidth;