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;
}
const char* pch = string;
int width = 0;
int stringWidth = 0;
while (*pch != '\0') {
int v3;
int v4;
while (*string != '\0') {
unsigned char ch = static_cast<unsigned char>(*string++);
if (*pch == ' ') {
v3 = gCurrentInterfaceFontDescriptor->letterSpacing;
v4 = gCurrentInterfaceFontDescriptor->wordSpacing;
int characterWidth;
if (ch == ' ') {
characterWidth = gCurrentInterfaceFontDescriptor->wordSpacing;
} else {
v3 = gCurrentInterfaceFontDescriptor->glyphs[*pch & 0xFF].width;
v4 = gCurrentInterfaceFontDescriptor->letterSpacing;
}
width += v3 + v4;
pch++;
characterWidth = gCurrentInterfaceFontDescriptor->glyphs[ch].width;
}
return width;
stringWidth += characterWidth + gCurrentInterfaceFontDescriptor->letterSpacing;
}
return stringWidth;
}
// 0x4421DC