Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect glyph position with text outline #1826

Closed
cschreib opened this issue Oct 7, 2021 · 1 comment · Fixed by #1827
Closed

Incorrect glyph position with text outline #1826

cschreib opened this issue Oct 7, 2021 · 1 comment · Fixed by #1827

Comments

@cschreib
Copy link
Contributor

cschreib commented Oct 7, 2021

Subject of the issue

I am using SFML as one of multiple back-ends for a GUI library. I have experienced some issues with the outline glyph positions returned by sf::Font, see the : and + glyphs on the screenshot below (from current master):
Screenshot from 2021-10-07 07-53-15

Your environment

  • Your OS / distro / window manager used: Linux Mint 20.2 Cinnamon
  • Your version of SFML (2.5.0, git master, etc): master
  • Your compiler and compiler version used: GCC 9.3 and Clang 10 or 11
  • Special compiler flags used: none

Steps to reproduce

Tell us how to reproduce this issue. Please provide a minimal, complete and verifiable example, you can use the follow template as a start:

#include <SFML/Graphics.hpp>
#include <cmath>

int main() {
    sf::RenderWindow window(sf::VideoMode(768, 512), "Minimal, complete and verifiable example");
    window.setFramerateLimit(60);

    sf::Font fnt;
    fnt.loadFromFile("noto.ttf");

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear(sf::Color(128, 128, 128));

        float y = 0.0;
        for (std::size_t i = 5; i < 20; ++i) {
            sf::Text txt("Language: C++", fnt, i);
            txt.setFillColor(sf::Color::White);
            txt.setOutlineColor(sf::Color::Black);
            txt.setOutlineThickness(2.0f);
            txt.setPosition(0.0, std::round(y));
            window.draw(txt);

            y += 1.5f*i;
        }

        y = 0.0;
        for (std::size_t i = 5; i < 20; ++i) {
            sf::Text txt("Language: C++", fnt, i);
            txt.setFillColor(sf::Color::White);
            txt.setStyle(sf::Text::Bold);
            txt.setOutlineColor(sf::Color::Black);
            txt.setOutlineThickness(2.0f);
            txt.setPosition(256.0, std::round(y));
            window.draw(txt);

            y += 1.5f*i;
        }

        y = 0.0;
        for (std::size_t i = 5; i < 20; ++i) {
            sf::Text txt("Language: C++", fnt, i);
            txt.setFillColor(sf::Color::White);
            txt.setStyle(sf::Text::Italic);
            txt.setOutlineColor(sf::Color::Black);
            txt.setOutlineThickness(2.0f);
            txt.setPosition(512.0, std::round(y));
            window.draw(txt);

            y += 1.5f*i;
        }

        window.display();
    }
}

Expected behavior

The outline (black) for the : and + glyphs should be rendered well centred behind the non-outline (white) glyph.

Actual behavior

They are not.

@cschreib
Copy link
Contributor Author

cschreib commented Oct 7, 2021

I have a proposed fix in #1827.

@Bromeon Bromeon linked a pull request Oct 7, 2021 that will close this issue
9 tasks
@eXpl0it3r eXpl0it3r added this to Discussion in SFML 2.6.0 via automation Oct 18, 2021
@eXpl0it3r eXpl0it3r added this to the 2.6 milestone Oct 18, 2021
@eXpl0it3r eXpl0it3r moved this from Discussion to Done in SFML 2.6.0 Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
SFML 2.6.0
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants