diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 79b7567ba..72a8ae827 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -210,6 +210,20 @@ var integer_zoom := false: ## Found in Preferences. The scale of the interface. var shrink := 1.0 +var theme_font := loaded_fonts[theme_font_index]: + set(value): + theme_font = value + if is_instance_valid(control) and is_instance_valid(control.theme): + control.theme.default_font = theme_font +## Found in Preferences. The index of the font used by the interface. +var theme_font_index := 1: + set(value): + theme_font_index = value + if theme_font_index < loaded_fonts.size(): + theme_font = loaded_fonts[theme_font_index] + else: + var font_name := get_available_font_names()[theme_font_index] + theme_font = find_font_from_name(font_name) ## Found in Preferences. The font size used by the interface. var font_size := 16 ## Found in Preferences. If [code]true[/code], the interface dims on popups. @@ -277,6 +291,7 @@ var tool_button_size := ButtonSize.SMALL: return tool_button_size = value Tools.set_button_size(tool_button_size) +## Found in Preferences. var share_options_between_tools := false: set(value): share_options_between_tools = value diff --git a/src/Autoload/Themes.gd b/src/Autoload/Themes.gd index 4db8c8340..b9d47076b 100644 --- a/src/Autoload/Themes.gd +++ b/src/Autoload/Themes.gd @@ -43,6 +43,8 @@ func remove_theme(theme: Theme) -> void: func change_theme(id: int) -> void: theme_index = id var theme := themes[id] + if theme.default_font != Global.theme_font: + theme.default_font = Global.theme_font theme.default_font_size = Global.font_size theme.set_font_size("font_size", "HeaderSmall", Global.font_size + 2) var icon_color := theme.get_color("modulate_color", "Icons") diff --git a/src/Preferences/PreferencesDialog.gd b/src/Preferences/PreferencesDialog.gd index 074cdc7b6..c662950d4 100644 --- a/src/Preferences/PreferencesDialog.gd +++ b/src/Preferences/PreferencesDialog.gd @@ -9,6 +9,7 @@ var preferences: Array[Preference] = [ ), Preference.new("ffmpeg_path", "Startup/StartupContainer/FFMPEGPath", "text", ""), Preference.new("shrink", "%ShrinkSlider", "value", 1.0), + Preference.new("theme_font_index", "%FontOptionButton", "selected", 1), Preference.new("font_size", "%FontSizeSlider", "value", 16), Preference.new( "dim_on_popup", "Interface/InterfaceOptions/DimCheckBox", "button_pressed", true @@ -292,6 +293,10 @@ func _ready() -> void: language.add_child(button) button.pressed.connect(_on_language_pressed.bind(button.get_index())) + # Add fonts to the font option button + for font_name in Global.get_available_font_names(): + %FontOptionButton.add_item(font_name) + for pref in preferences: if not right_side.has_node(pref.node_path): continue diff --git a/src/Preferences/PreferencesDialog.tscn b/src/Preferences/PreferencesDialog.tscn index 5f939baf4..411e305ad 100644 --- a/src/Preferences/PreferencesDialog.tscn +++ b/src/Preferences/PreferencesDialog.tscn @@ -205,6 +205,15 @@ layout_mode = 2 mouse_default_cursor_shape = 2 text = "Apply" +[node name="FontLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions"] +layout_mode = 2 +size_flags_horizontal = 3 +text = "Font:" + +[node name="FontOptionButton" type="OptionButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions"] +unique_name_in_owner = true +layout_mode = 2 + [node name="DimLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/InterfaceOptions"] layout_mode = 2 size_flags_horizontal = 3