SFML community forums
Help => Graphics => Topic started by: akhena on September 04, 2011, 03:59:28 pm
-
Hello,
I finally made a "minimal" code to show the bug I had when displaying some text. I know this problem doesn't happen on all computers, as it doesn't on my laptop. Nevertheless, I thought it might be of interest.
If anyone has an idea to help me find the culprit, I would appreciate.
#include <iostream>
#include <list>
#include <vector>
#include <SFML/Graphics.hpp>
using namespace std;
int main()
{
sf::Font font;
// Create a window and its view
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
// Load font
if (!font.LoadFromFile("comic.ttf"))
{
std::cout << "Could not load font." << std::endl;
return EXIT_FAILURE;
}
typedef std::list<std::string> StringList;
StringList stringList;
stringList.push_back("Test avec le texte");
stringList.push_back("éèàêzZaA ù");
stringList.push_back("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
stringList.push_back("abcdefghijklmnopqrstuvwxyz");
stringList.push_back("éèàê");
std::vector<sf::Text> textLines;
float lastLinePosition = 0.f;
for(std::list<std::string>::iterator line = stringList.begin(); line != stringList.end();
++ line)
{
sf::Text textLine(*line, font, 20);
textLine.SetColor(sf::Color::Red);
sf::Vector2f position;
position.x = 10.f;
position.y = std::floor(10.f + lastLinePosition + 0.5);
textLine.SetPosition(position);
textLines.push_back(textLine);
lastLinePosition += font.GetLineSpacing(20);
}
// Start the game loop
while (window.IsOpened())
{
// Process events
sf::Event event;
while (window.PollEvent(event))
{
// Close window : exit
if (event.Type == sf::Event::Closed)
window.Close();
}
// Clear screen
window.Clear();
for(std::vector<sf::Text>::iterator line = textLines.begin(); line != textLines.end();
++line)
{
window.Draw(*line);
}
// Update the window
window.Display();
}
return EXIT_SUCCESS;
}
Of course you'll need comic.ttf in your folder. But I guess this font can be found on most computers...
I'm running this on an AMD 2400++ with an ATI Radeon 9600 graphic card. I already tried to install the latest driver, with no success.
You can find my print screen here : http://imageshack.us/f/684/sfmltext.jpg
The problem appears on the 4th line.
-
Ok, sorry for my answer...
I was sure I've seen a topic like that recently...
Need some rest...
-
It works for me, so... it will be hard to find out what's wrong :?
I think there are a lot of topic about that on SFML forum...
Try the Search function
???
-
Ok i'm not mad, I've effectively seen a question like that, but on French part of the forum.
Link : http://www.sfml-dev.org/forum-fr/viewtopic.php?t=3747
The problem was an "old" build of SFML2
Have you the last build of SFML ?
-
Thanks for the link, unfortunately it doesn't solve my problem. :(
-
Hi!
The same issue here:
(https://legacy.sfmluploads.org/cache/pics/113_text-artifact.png)
Is there a solution or a workaround for this?
-
Today I've tested it on Windows XP and Windows 7, and the same glitch is present, see the image above.
-
I found the problem, you're using comic sans. Switch to pretty much any other font and it'll look a lot better ;)
Just kidding, a bit.
-
I found the problem, you're using comic sans.
Heheh, no it's 'Cheeseburger', the basic font that came along with the pong example in SFML! :)
-
I am also having this problem unfortunately.
I'm using the latest sfml2 version.
It seems to only happen on some computers.
I tried a few different ttf fonts.
On windows 7 64-bit I actually have no problems,
but a friend sees it on their machine with vista64, intel graphics.
I can also see the problem when using a windowsXP 32-bit on a virtual machine.