Fit_content not working for custom RichTextLabels

Godot Version

v4.2.1

Question

I created a custom class based on RichTextLabel and set fit_content to true in that scene, let’s say the class_name is CustomRTL, I tried:

var custom_rtl = CustomRTL.new()

custom_rtl.text = “a”

add_child(custom_rtl)

And get nothing in the screen. Before it I tried with custom Label and it works just fine. I thought the major difference between a Label and a RichTextLabel is the fit_content property as in its description it says setting fit_content property to true would make RichTextLabel behave like Label, but it didn’t.

Then I tried modifying minimum sizes and many others, and still nothing. I use print(size) to get the size values, the Y is always 0.

Finally I gave up and tried another way to use the scene, which is:

@export var custom_rtl_scene: PackedScene

var custom_rtl = custom_rtl_scene.instantiate()

custom_rtl.initiate(“a”)

add_child(custom_rtl)

And now it works. Everything displays normally. Why is that? There must be something I’m missing in the first approach, what could that be?