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.jpgThe problem appears on the 4th line.