0 votes

The label was created with gdscript, and I need to set its font data via gdscript. How do I do this?

in Engine by (7,190 points)

What do you mean by "Font Data"? Are you asking if you can edit how the font looks with script? Because you could just download a font from the internet (I recommend https://www.dafont.com/ as it is widley used and trusted by game developers and media producers alike) or create one yourself with many programs which are available online.

No, I already have the font data downloaded. What I need to do is to assign it to the attribute in the label node, and I'm not sure how to do that via code.

1 Answer

+1 vote
Best answer
func _ready():
    var dynamic_font = DynamicFont.new()
    dynamic_font.font_data = load("<Path To Font-File>")
    $Label.add_font_override("font", dynamic_font)
by (10,311 points)
selected by

Thanks, it worked!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.