View Issue Details

IDProjectCategoryView StatusLast Update
0001284Spring engineGeneralpublic2009-05-29 00:43
ReporterEvil4Zerggin Assigned TojK  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.77b5 
Fixed 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

Activities

Evil4Zerggin

2009-01-19 06:59

reporter   ~0003216

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

MelTraX

2009-01-19 10:29

reporter   ~0003220

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

Evil4Zerggin

2009-01-23 18:14

reporter   ~0003235

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

quantum

2009-01-31 05:22

reporter   ~0003240

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

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