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 (252 points)

1 Answer

+2 votes
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,476 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.

Where you able to change the theme/font for the dropdown? I have been struggling with this for hours, no luck.

Creating a theme for the OptionButton and assigning a font to that theme worked for me.

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 Frequently asked questions and 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 [email protected] with your username.