0 votes

Hi. Changing the font of an OptionButton only affects the selected item. I'd like to also set the same font to the dropdown list. How do I do it?

Thanks in advance.

in Engine by (244 points)

1 Answer

+1 vote
Best answer

The only way I know to do this, is by creating a new theme that uses the font.
But for some reason the item button disappears from the toolbar when doing this.

So I think you would have to edit your items from script, maybe there is an other way but I have no idea how to work with themes.

What I do to avoid this is creating the theme in the ready() function only when my app is running.

func _ready():
    $OptionButton.theme = Theme.new()
    $OptionButton.theme.default_font = DynamicFont.new()
    $OptionButton.theme.default_font.font_data = load("res://your_font_file")

That way you can still easily edit your items from the editor.

by (1,457 points)
selected by

You are right, I had to create a theme for the font to work, but in my case doing it through the editor worked.
Now I have to make the style of the button work on the dropdown list...

Thanks for your time.

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.