Why does Label's size does not change?

Godot Version

v4.3.stable.official [77dcf97d8]

Question

Why does Label's size does not change?

Label’s script

extends Label


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
  print("Before edit")
  print('self.get_theme_font_size("font_size") -> ', self.get_theme_font_size("font_size"))
  print('self.size -> ', self.size)
  self.add_theme_font_size_override("font_size", 50)
  self.reset_size()
  print("After edit")
  print('self.get_theme_font_size("font_size") -> ', self.get_theme_font_size("font_size"))
  print('self.size -> ', self.size)

Output

Godot Engine v4.3.stable.official.77dcf97d8 - https://godotengine.org
OpenGL API 3.3 (Core Profile) Mesa 22.3.6 - Compatibility - Using Device: Intel - Mesa Intel(R) HD Graphics 3000 (SNB GT2)

Before edit
self.get_theme_font_size("font_size") -> 30
self.size -> (189, 42)
After edit
self.get_theme_font_size("font_size") -> 50
self.size -> (189, 69)
--- Debugging process stopped ---


This could be several things, like Clip Text being on. What does it look like once you’ve changed the size?

Also, you do not need to use self to fetch properties on a node like this. You can just call them directly.

Clip Text is false
After editing, size should be (315, 69) not (189, 69), size.x didn’t change

Okay, but how does it actually look? Could you post a screenshot?

Decided to test, since the label and text does get visually bigger. The size of the label seems to need a frame to update.

Adding await(get_tree().process_frame) before you check the size, gives the expected result.

Thank you so much

1 Like