Remove TextEdit padding

Godot Version

4.5

Question

The TextEdit field appears to have this weird padding unrelated to the stylebox. Anyone know how to get rid of that? I want it to conform to the text like a Label (so that it will accurately wrap to how the label will display it), but I have had no success in figuring out where this padding is getting added.
Mll1Yvy

What padding? Try setting the TextEdit.line_spacing theme property to 0

The padding above and to the right of the text. There is only one line, so line_spacing has little effect. Also, I want the lines to be spaced normally when the user enters text in.
image

That may be your font. Fonts are notoriously spotty about the accuracy of glyph bounding boxes.

Issue occurs regardless of font.
image

Can you post the stats for the stylebox? Make sure you don’t have things like external padding…

Are you centering the text vertically and horizontally?

Is the TextEdit embedded in anything?

This is a TextEdit field, so I cannot center the text (nor would I wish to, as it is intended for user input). The node is currently set to fit content height and width, but toggling these has no effect on the padding. The stylebox has some left padding, as otherwise the text will touch the left edge of the field, but it has no padding otherwise (setting these to zero has no effect). The padding does not come from the stylebox as mentioned above.

Do you need multiline? If not, LineEdit might be easier to work with.

There are other values that can affect the padding; there’s an expand thing that pushes the stylebox outside of its nominal bounding rectangle, for example.

I do need to multiline. Expand Margins appears to have no effect on this node, which is in a VBoxContainer; but I doubt it would be relevant anyway, as this is not a margin, it is padding.

Unless something is going on in the hierarchy above, I’m not sure what would cause this. I can’t reproduce it here.

It seems reproducible to me. What does yours look like? (This is with StyleBoxEmpty)

Just for laughs, try setting line_spacing to -8 or so.

Unfortunately this does not affect the end padding at all.

It’s not going to affect the end spacing because it’s multiline and editable. I could be wrong, but I don’t think you can get TextEdit to auto-center the current text like that unless you set it to center justify.

I don’t want to center the text. I want to remove all outside padding.

As mentioned in the original post, I would like the text inside the TextEdit to appear exactly the same as it would inside a Label of equal size.

It’s not designed to do that, presumably because it’s editable and therefore the contents (and their size) are expected to change.

It’s not an issue of the size of the contents. The issue is that, regardless of whether you set it to fit content or scroll, there is always right padding in the node, preventing the text from wrapping correctly. It doesn’t make any sense why it would not be designed to do that, given that it has autowrap, and you can hide the scroll bars.

Here is a mockup of what I mean. The TextEdit field on the left has been given StyleBoxEmpty to match the right Label. They both have the same font and font size (the default for Godot). They do not wrap the same, for no apparent reason.

I’m not sure why that is, honestly, but there’s more to it than that; the two examples you gave have different line spacing as well.

The line spacing is largely irrelevant to my concern. I can adjust the line spacing. I cannot adjust the padding.

The TextEdit doesn’t need to display exactly the same as the Label. But it has no chance of displaying anywhere close to the Label if this padding is not editable and the two therefore do not wrap the same way. This seems like a major oversight. Wouldn’t it be considered a normal use case to enter text into a TextEdit to be displayed in a Label?