Labels don't seem to center their text correctly

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GlitchGames

Red letter is where it should be, white text is where the label is centering its text
Red letter is where it should be, white text is where the label is centering its text

In this image, I enabled drawing the Rect of the label. You can see that it is even being drawn outside of the box
In this image, I enabled drawing the Rect of the label. You can see that it is even being drawn outside of the box

I am using all this code to center it properly, but I just can’t see where I’m going wrong. I can use draw_string and center it, like how you see in the red text, but the Labels are just going wrong.

labelBig.set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER) labelBig.set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER) labelBig.set_h_grow_direction(Control.GROW_DIRECTION_BOTH) labelBig.set_v_grow_direction(Control.GROW_DIRECTION_BOTH) labelBig.set_autowrap_mode(TextServer.AUTOWRAP_OFF)

What’s more, the further away the label is from the center of the screen, the worse it gets. But when I, for example, drag one label from the right side over to the left side, the decentering stays the same. It doesn’t fix itself or change sides, it shows the same way as if it had not moved at all.

I am having issues making the images show, so I’m just gonna post imgur links

Imgur provides a number of different image link styles for any given image. To get an Imgur-based image to show up in your post, I know either of the following should work:

  • The direct link (in conjunction with the forum’s Image button)
  • The HTML link, pasted directly into the post content

jgodfrey | 2023-05-24 22:47

I’m curious if your results vary depending on the font used?

jgodfrey | 2023-05-24 22:53

As for the imgur link, I tried a few things, sadly not even embedding seems to work unless I am being stupid in some unknown way.

And I tried the label thing with a different font I had at hand, same result.

GlitchGames | 2023-05-25 00:47

The Imgur suggestions should work. Here’s both in action (ignore the contents of the image - just something I have available on Imgur…)

Direct link, used in conjunction with the Image feature:

enter image description here

And, directly pasted HTML link…

jgodfrey | 2023-05-25 00:57

There you go, I believe that works.

But yeah, label issue persists, no clue. Using Labels lets me not tank my performance, as opposed to using _draw to render text directly, but I have this weird issue happening. Sad days.

GlitchGames | 2023-05-25 01:35