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

Author Topic: Text rendering problem  (Read 3839 times)

0 Members and 1 Guest are viewing this topic.

akhena

  • Newbie
  • *
  • Posts: 10
    • View Profile
Text rendering problem
« 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.

Code: [Select]
#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.

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Text rendering problem
« Reply #1 on: September 04, 2011, 04:13:41 pm »
Ok, sorry for my answer...
I was sure I've seen a topic like that recently...
Need some rest...

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Text rendering problem
« Reply #2 on: September 04, 2011, 04:14:33 pm »
It works for me, so... it will be hard to find out what's wrong :?

Quote
I think there are a lot of topic about that on SFML forum...
Try the Search function

???
Laurent Gomila - SFML developer

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Text rendering problem
« Reply #3 on: September 04, 2011, 04:28:36 pm »
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 ?

akhena

  • Newbie
  • *
  • Posts: 10
    • View Profile
Text rendering problem
« Reply #4 on: September 04, 2011, 06:13:02 pm »
Thanks for the link, unfortunately it doesn't solve my problem.   :(

easy

  • Full Member
  • ***
  • Posts: 146
    • MSN Messenger - easy82.contact@gmail.com
    • View Profile
    • Email
Text rendering problem
« Reply #5 on: September 07, 2011, 11:16:09 pm »
Hi!

The same issue here:


Is there a solution or a workaround for this?

easy

  • Full Member
  • ***
  • Posts: 146
    • MSN Messenger - easy82.contact@gmail.com
    • View Profile
    • Email
Text rendering problem
« Reply #6 on: September 10, 2011, 12:47:53 am »
Today I've tested it on Windows XP and Windows 7, and the same glitch is present, see the image above.

Kian

  • Newbie
  • *
  • Posts: 44
    • View Profile
Text rendering problem
« Reply #7 on: September 10, 2011, 03:52:50 am »
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.

easy

  • Full Member
  • ***
  • Posts: 146
    • MSN Messenger - easy82.contact@gmail.com
    • View Profile
    • Email
Text rendering problem
« Reply #8 on: September 10, 2011, 03:25:06 pm »
Quote from: "Kian"
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! :)

mbro2k

  • Newbie
  • *
  • Posts: 7
    • View Profile
Text rendering problem
« Reply #9 on: September 25, 2011, 08:34:44 pm »
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.