2025-07-21 13:49 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001284Spring engineGeneralpublic2009-05-29 00:43
ReporterEvil4Zerggin 
Assigned TojK 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version0.77b5 
Target VersionFixed in Version0.79.0.0 
Summary0001284: gl.GetTextWidth Returns Wrong Result
DescriptionI think this started happening before 0.78, but gl.GetTextWidth doesn't return the correct result.(At one point it worked correctly.) So far as I can tell, the issue is:

const float width = font->CalcTextWidth(text.c_str()) / fontHeight;
lua_pushnumber(L, width);

Why is the result being divided by fontHeight? fontHeight is not used in gl.Text's justification:

if (right) {
  xj -= fontScale * font->CalcTextWidth(text.c_str());
} else if (center) {
    xj -= fontScale * font->CalcTextWidth(text.c_str()) * 0.5f;
}

which produces the correct visual result.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files

-Relationships
+Relationships

-Notes

~0003216

Evil4Zerggin (reporter)

After some testing, it appears that this isn't the problem. Not sure what is, though.

~0003220

MelTraX (reporter)

I can confirm this btw. Code that worked for IceUI a few releases back was untouched and doesn't work anymore.

~0003235

Evil4Zerggin (reporter)

As far as I can tell it has something to do with view sizes; for now I'm using

local function GetRealTextWidth(text)
    return glGetTextWidth(text) * vsx / vsy * 1.33333333
end

~0003240

quantum (reporter)

It seems that gl.Text produces text that is streched with the aspect ratio, probably to make it fit in the vanilla spring gui buttons. It looks like gl.Scale(viewSizeY/viewSizeX * 3/4, 1, 1) compensates for it and causes gl.GetTextWidth to be correct, but it also makes the text hard to read due to more resizing. Example with text size 12: http://img264.imageshack.us/img264/1207/ss20090131051920ef8.png
+Notes

-Issue History
Date Modified Username Field Change
2009-01-17 22:40 Evil4Zerggin New Issue
2009-01-19 06:59 Evil4Zerggin Note Added: 0003216
2009-01-19 10:29 MelTraX Note Added: 0003220
2009-01-23 18:14 Evil4Zerggin Note Added: 0003235
2009-01-31 05:22 quantum Note Added: 0003240
2009-05-29 00:43 jK Status new => resolved
2009-05-29 00:43 jK Fixed in Version => 0.79.0.0
2009-05-29 00:43 jK Resolution open => fixed
2009-05-29 00:43 jK Assigned To => jK
+Issue History