#3745·SFML

`setLineAlignment` set to Center/Right makes `getGlobalBounds` incorrect

Author: ZombieschannelCreated Aug 14, 2026Updated Aug 14, 2026
Labelsbug

Prerequisite Checklist

Describe your issue here

getGlobalBounds for text does not seem to have the correct position when setLineAlignment is set anything but Left.

In the below image you can see the below shown code for each of the setLineAlignment values: top image is line alignment set to left, center is center and bottom image is right.

The size of getGlobalBounds remains the same, the position changes, which in the below example I am correcting for, so it still should be covering the whole render texture.

Line alignment set to center seems to move text by half a pixel and line alignment set to right seems to move text by a whole pixel, in which case part of it is drawn outside of the render texture.

I've tested this with a few fonts but below example is the impact font.

Image

Your Environment

  • SFML version: 3.1.0

Steps to reproduce

cpp
int main()
{
    Font f("/usr/share/fonts/Impact-Font-Family/impact.ttf");
    Text t(f);
    t.setString("Test");
    t.setLineAlignment(Text::LineAlignment::Left);
    err() << t.getGlobalBounds().position.x << " " << t.getGlobalBounds().position.y << " " << t.getGlobalBounds().size.x << " " << t.getGlobalBounds().size.y << endl;
    t.setPosition(-t.getGlobalBounds().position);
    RenderTexture tex;
    tex.resize(Vector2u(t.getGlobalBounds().size));
    tex.clear();
    tex.draw(t);
    tex.display();
    tex.getTexture().copyToImage().saveToFile("bug.png");
}

Expected behavior

Global bounds are correct.

Actual behavior

Global bounds are not correct.