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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ChristResurrection

Pages: [1]
1
Oh, it was a silly mistake in this test case, which works properly now, thank you.
However, I am still having troubles with text positioning. I am trying to put my text at the bottom (or center) of the shape by vertical axis. For some reason the text appears slightly lower than it should be (origin is always at (0, 0)).
text.setPosition(text->getPosition().left,
                          -text.getGlobalBounds().height +
                          shape.getGlobalBounds().top + shape.getGlobalBounds().height
);
 

I tried aligning the text by setting its origin to bottom, but it results in the same picture. I would like to know what am I doing wrong.

2
Graphics / sf::Text::GetGlobalBounds() returns misaligned rectangle?
« on: April 10, 2014, 01:19:39 pm »
Good morning (afternoon, evening, depending on where you are). I think I have encountered a small problem with GetGlobalBounds().
I was not able to position my text properly so I tried to draw a rectangle using Text::GetGlobalBounds() for its position:
test.setPosition(txt.getPosition());
test.setSize(sf::Vector2f(txt.getGlobalBounds().width, txt.getGlobalBounds().height));

As you can see, the rectangle is not properly matching the bounding box of the text.
My text loads font from verdana.ttf, which is a default Windows font, and has its character size set to 64. Text style is not changed ("regular").
Is this a bug, or am I just missing something? Thanks in advance.

Pages: [1]