How to change the font of the dropdown list of an OptionButton?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gabriel

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.

:bust_in_silhouette: Reply From: Adam_S

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.

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.

Gabriel | 2019-09-25 13:12

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

jeudyx | 2022-07-19 06:15

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

Erfa | 2022-08-01 19:37