Hello,
Im trying to write a simple Label class which, for now, is supposed to draw a sf::text object on the screen with an rectangle surrounding it.
Im doing that by first drawing the text at the destined position and then using the text's globalposition to get the rectangle at the proper position. This works and always creates a fitting rectangle around the text, but what i actually want is to do this the other way around:
i create the background(with a fixed size) and then make the text fit it. Setting the character size of the sf::text does not give one proper control over the actual size of the text(or so it seems) and i can not like directly set the localBounds so the only solution i see right now is to solve this by iterating over possible character size's and sf::text positions.
In short:
What i wanna do in the end is to have a label with enough space for three digits of a certain size.
But i want it in this direction:
I define the (fix)size of the background rectangle(or later an image, but thats not the problem right now) and then compute the size and positon of the sf::text to properly fit my rectangle(so that neither a 1digit number nor a 3 digit number is out of the rectangle).
Thank you very much