Review interfaceFontGetStringWidthImpl

This commit is contained in:
Alexander Batalov 2022-10-30 08:41:00 +03:00
parent 37f7ecc1c3
commit 3015f39368
1 changed files with 9 additions and 13 deletions

View File

@ -236,26 +236,22 @@ static int interfaceFontGetStringWidthImpl(const char* string)
return 0; return 0;
} }
const char* pch = string; int stringWidth = 0;
int width = 0;
while (*pch != '\0') { while (*string != '\0') {
int v3; unsigned char ch = static_cast<unsigned char>(*string++);
int v4;
if (*pch == ' ') { int characterWidth;
v3 = gCurrentInterfaceFontDescriptor->letterSpacing; if (ch == ' ') {
v4 = gCurrentInterfaceFontDescriptor->wordSpacing; characterWidth = gCurrentInterfaceFontDescriptor->wordSpacing;
} else { } else {
v3 = gCurrentInterfaceFontDescriptor->glyphs[*pch & 0xFF].width; characterWidth = gCurrentInterfaceFontDescriptor->glyphs[ch].width;
v4 = gCurrentInterfaceFontDescriptor->letterSpacing;
}
width += v3 + v4;
pch++;
} }
return width; stringWidth += characterWidth + gCurrentInterfaceFontDescriptor->letterSpacing;
}
return stringWidth;
} }
// 0x4421DC // 0x4421DC