mirror of
https://github.com/wiiu-env/libgui.git
synced 2024-06-02 09:28:50 +02: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; }
|
if (!text) { return 0; }
|
||||||
|
|
||||||
uint16_t strWidth = 0;
|
uint16_t strWidth = 0;
|
||||||
FT_Vector pairDelta;
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
|
|
||||||
while (text[i]) {
|
while (text[i]) {
|
||||||
ftgxCharData *glyphData = cacheGlyphData(text[i], pixelSize);
|
strWidth += getCharWidth(text[i], pixelSize, i > 0 ? text[i - 1] : 0);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
return strWidth;
|
return strWidth;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user