How can i control Label node's font size in my script?

<godot ver 4>

i want to change my font size in my script!

it should fix some event happens. so i wrote my lines like

func score_fever(score):
if score > 10:
if score < 21:
update_scoreMulti(“2x”)
$ScoreMulti.font_size = 16
$ScoreMulti.show()

but it makes error when the event happens…

error message:
invaild set index ‘font_size’(on base:‘Label’) with value of type ‘int’.

how can i fix my fontsize in my script? :smiling_face_with_tear: :smiling_face_with_tear: :smiling_face_with_tear:

Well, I know two ways to achieve that (I assume your $Score reference it’s a Label node):

1 - LabelSettings
You can create a LabelSettings object and assign it to the Label so you can modify the properties. You can even save this as as a pre-made resource and assign it to the label if you don’t want to be creating it all the time

$Score.label_settings = LabelSettings.new()
$Score.label_settings.font_size = 16
	

2 - Theme override
Simply override the font size of this label theme:

$Score.add_theme_font_size_override("font_size", 16)

1 Like

wow, thank you brooooo

i could’t solve my problem but i can have new knowledge that can be help. :slight_smile:

is there a way can change some font to font preset what i saved?