Resize instantiated label after setting text

Godot Version

4.3 mono stable

Question

I can’t seem to figure out how to make the label get resized for the text inside.

Here’s my code :

			var label = AnimatedLabel.Instantiate<Label>();
			ApplyStyleToLabel(label);
			label.Text = c.ToString();
			label.UpdateMinimumSize();
			label.ResetSize();
			GD.Print(label.Size);

And no matter what character I put in I get (1, 46) which is the size of the label in the packed instance. I tried as you can see adding calls to UpdateMinimumSize and ResetSize hoping it would do something but no luck.

Oddly enough, if I just create a new label from code instead of instantiating it, I get this weird behavior :

			var label = new Label();
			ApplyStyleToLabel(label);
			label.Text = c.ToString();
			GD.Print(label.Size);
			label.Position = _textPos;
			GD.Print(label.Size);

Before I set the position, the size is (0, 0), after I set the position, the size is correct for the character.

Can anyone please help me with this?

This worked :

			label.Text = c.ToString();
			label.Size = label.GetMinimumSize();

But I’ll leave the post open for a bit in case someone has an explanation for this behavior.