SFML community forums

Help => Graphics => Topic started by: codemonkey on September 26, 2011, 03:08:54 pm

Title: [SFML2] Bounding boxes around sf::Text characters
Post by: codemonkey on September 26, 2011, 03:08:54 pm
I'm having a weird issue after upgrading to SFML 2 on OS X (Lion - 10.7.1), i have tried a lot of different things, including trying other fonts (and other font formats), i also  just updated my SFML build to latest commit (0fd992d56e23859f25057ea2878c7e19eced294a (https://github.com/SFML/SFML/commit/0fd992d56e23859f25057ea2878c7e19eced294a)) from git.

But i still keep randomly getting bounding boxes around characters:
(http://dotsquare.dk/sfml_issue.png)

I'm doing nothing special to draw the text in this example:
Code: [Select]
sf::Text LoadingText;
    LoadingText.SetFont(DeliciousFont);
    LoadingText.SetColor(greenColor);
    LoadingText.SetString("Retreiving information from jukebox...");
    LoadingText.SetCharacterSize(80.0f);
    LoadingText.SetPosition(App.GetWidth() / 2 - LoadingText.GetRect().Width / 2, App.GetHeight() / 2 - LoadingText.GetRect().Height / 2);


Has anyone experienced similar issues? I'm thinking of trying to build the project on windows now, to see if it makes a difference, but i really want it to work on OS X to.
Title: [SFML2] Bounding boxes around sf::Text characters
Post by: Grimshaw on September 27, 2011, 02:58:53 am
Any chance you're messing with OpenGL directly? seems like a possible blending state gone wrong, but at the same time i wouldnt bet on it :)

Maybe its something Mac specific, to which i cant be any help
Title: [SFML2] Bounding boxes around sf::Text characters
Post by: codemonkey on September 27, 2011, 02:46:36 pm
Unfortunaly i'm not doing any calls directly to OpenGL, and as far as i can see.

I'm using the default settings context and this both happens in windowed and fullscreen mode.
Title: [SFML2] Bounding boxes around sf::Text characters
Post by: luiscubal on September 27, 2011, 03:15:56 pm
This issue doesn't seem to be exclusive of Mac OS X.
I've had a very similar problem - text with bounding boxes appearing on some characters -  on Linux(I don't remember if it also happened on Windows).
Sadly, I don't know any workarounds.
Title: [SFML2] Bounding boxes around sf::Text characters
Post by: Haikarainen on September 27, 2011, 03:19:51 pm
Set character size to int instead of float (80 instead of 80.0f) and it should work. Had similiar issues with my own tile-manager-class
Title: [SFML2] Bounding boxes around sf::Text characters
Post by: Laurent on September 27, 2011, 09:21:24 pm
This is a known bug, but unfortunately it hasn't been fixed yet.

Quote
Set character size to int instead of float (80 instead of 80.0f) and it should work

SetCharacterSize takes an integer anyway, so that won't change anything.
Title: [SFML2] Bounding boxes around sf::Text characters
Post by: efess on October 04, 2011, 04:10:55 am
I run into this as well, however only in Debug mode when I have unmanaged debugging enabled in my managed c# project (Visual Studio 2010).

Doesn't happen when this is unchecked, or in release configuration, so it's not really a big issue for me - hope this helps though.
Title: Re: [SFML2] Bounding boxes around sf::Text characters
Post by: jorgeh on May 20, 2012, 09:08:41 am
Has anybody found a solution? I'm running into the same problem (also OS X 10.7, SFML 2)
Title: Re: [SFML2] Bounding boxes around sf::Text characters
Post by: Laurent on May 20, 2012, 09:24:13 am
There's no solution, it's a bug in SFML that hasn't been fixed yet.
Title: Re: [SFML2] Bounding boxes around sf::Text characters
Post by: DavidJohns on August 28, 2012, 02:08:28 pm
Just wondering if there has been progress on this and if anyone has discovered some work arounds?  On my machine it is really bad.  Using SFML-2 on Xcode and the template project, just by adding enough text I get boxes around characters.  In the the example below, everything from 1 onwards is bounded.  I'm working on an app that's using tons of text, this could kill it


 if (!font.loadFromFile(resourcePath() + "sansation.ttf"))
        return EXIT_FAILURE;
    sf::Text text("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefg??", font, 30);
    text.setColor(sf::Color::Black);
Title: Re: [SFML2] Bounding boxes around sf::Text characters
Post by: Laurent on August 28, 2012, 04:15:27 pm
Quote
Just wondering if there has been progress on this and if anyone has discovered some work arounds?
No :(
Title: Re: [SFML2] Bounding boxes around sf::Text characters
Post by: conleec on September 14, 2019, 02:16:33 am
I was having the same problem while working thru a tutorial on LinkedIn Learning. Ultimately, I found that if I used a non-fractional number for both the "x" and "y" coordinates as in:

 textObject.setPosition((int)xPos, (int)yPos)

...it would work. Is there anything inherently wrong with doing this? In my case it was only for the "Score =" line, so it didn't really need to move or animate, per se. The reason I had a fractional number in the first place, is because I implemented some code to "scale" the text and position of the text based on the size of the game window.

Chris