Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: CSFML 2.3 render text GetLocalBounds bug  (Read 3255 times)

0 Members and 1 Guest are viewing this topic.

mkalex777

  • Full Member
  • ***
  • Posts: 206
    • View Profile
CSFML 2.3 render text GetLocalBounds bug
« on: May 29, 2016, 04:25:32 pm »
I'm using UbuntuMono-R.ttf
MD5: 9383F4B0BC1D264A5A7E094EB1ED0C0B
Link: http://db.onlinewebfonts.com/t/9383f4b0bc1d264a5a7e094eb1ed0c0b.ttf

It's monospace font, and it works fine with different strings - all letters with the same size.

But now I found two strings, for which Text::GetLocalBounds returns incorrect sizes.
It happens with Text::CharacterSize = 20.

Example:

string "Level:" => size = [59; 26] (bounds = [FloatRect] Left=2; Top=6; Width=55; Height=14)
string "Xp:   " => size = [60; 30] (bounds = [FloatRect] Left=0; Top=7; Width=60; Height=16)

I'm calculate text size from bounds with the following code:
        public static Vector2f MeasureText(this Text text)
        {
            var bounds = text.GetLocalBounds();
            var size = new Vector2f(bounds.Width, bounds.Height);
            var padding = new Vector2f(bounds.Left, bounds.Top);
            return size + padding * 2F;
        }
 

For both strings GetLocalBounds should return the same size.

Is it really CSFML 2.3 bug? Or may be it's just incorrect way to calculate the text size?
How to fix it in order to get the same size for both strings. Because the font is monospace.
« Last Edit: May 29, 2016, 04:33:47 pm by mkalex777 »

 

anything