getStringWidthFloat() possible bug?


#1

I was rendering a String character to the screen and was wondering why when I created a box around it, with width set to the character's width, it was way larger than the actual displayed character.   so I took a screenshot of said character in my app, and it's only 28px wide, according to the image I captured via Command-Shift-4. 

Line 644 says:

return w * font->height * font->horizontalScale;  

my font height was 132, and w was 0.38366428.   horizontalScale was 1

so, getStringWidthFloat() was returning 50.6436844, instead of 28.  

 

The question I have is: Is this a bug, or is my font's actual width larger than what gets displayed on the screen, and that could be the source of the error? 


#2

Interesting - that function should work for all standard fonts, as far as we know. Maybe you are using some funny font or some weird special character?


#3

I was using this font: http://www.fontspace.com/robert-allgeyer/musisync


#4

Well, that's exactly what I would call a funny font ;-) for stuff like this, please don't rely on the return value of getStringWidthFloat() — who knows what's going in in that font...