mirror of
https://github.com/wiiu-env/libgui.git
synced 2025-01-11 15:59:13 +01:00
Calucate the textWidth by using the CharWidth method in FreeTypeGX
This commit is contained in:
parent
92cd5c34fc
commit
6f91796cfc
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user