Repository: godotengine/godot (language: cpp)

Issue:
Font not inherited in theme type variation
### Godot version

4.1.1.stable

### System information

Ubuntu Linux 22.04, Nvidia

### Issue description

Creating a new theme type variation that inherits from a Base Type of Button does not inherit the font of the Button. Instead, it inherits from the Default Font for the theme and ignores the Base Type font. However, the inherited button does correctly inherit other properties like Styleboxes.

I expected the new button to inherit all of the properties of the base type including the font.

### Steps to reproduce

1. Create a new theme
2. Set a default font for the theme
3. Create a theme item for Button
4. Add a different custom font for the Button
5. Create a theme item called Button2
6. Set the Base Type for Button2 to Button
7. Add a Button to a scene
8. Set the Type Variation to Button2

### Minimal reproduction project

[ThemeTypeFontBug.zip](https://github.com/godotengine/godot/files/12372737/ThemeTypeFontBug.zip)



Discussion / hints:
This also applies to font size.

Fix patch:
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 9efb12fa11ea..8990994adaf1 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -513,6 +513,10 @@ bool Theme::has_font(const StringName &p_name, const StringName &p_theme_type) c
 	return ((font_map.has(p_theme_type) && font_map[p_theme_type].has(p_name) && font_map[p_theme_type][p_name].is_valid()) || has_default_font());
 }
 
+bool Theme::has_font_no_default(const StringName &p_name, const StringName &p_theme_type) const {
+	return (font_map.has(p_theme_type) && font_map[p_theme_type].has(p_name) && font_map[p_theme_type][p_name].is_valid());
+}
+
 bool Theme::has_font_nocheck(const StringName &p_name, const StringName &p_theme_type) const {
 	return (font_map.has(p_theme_type) && font_map[p_theme_type].has(p_name));
 }
@@ -616,6 +620,10 @@ bool Theme::has_font_size(const StringName &p_name, const StringName &p_theme_ty
 	return ((font_size_map.has(p_theme_type) && font_size_map[p_theme_type].has(p_name) && (font_size_map[p_theme_type][p_name] > 0)) || has_default_font_size());
 }
 
+bool Theme::has_font_size_no_default(const StringName &p_name, const StringName &p_theme_type) const {
+	return (font_size_map.has(p_theme_type) && font_size_map[p_theme_type].has(p_name) && (font_size_map[p_theme_type][p_name] > 0));
+}
+
 bool Theme::has_font_size_nocheck(const StringName &p_name, const StringName &p_theme_type) const {
 	return (font_size_map.has(p_theme_type) && font_size_map[p_theme_type].has(p_name));
 }
@@ -923,9 +931,17 @@ bool Theme::has_theme_item(DataType p_data_type, const StringName &p_name, const
 		case DATA_TYPE_CONSTANT:
 			return has_constant(p_name, p_theme_type);
 		case DATA_TYPE_FONT:
-			return has_font(p_name, p_theme_type);
+			if (!variation_map.has(p_theme_type)) {
+				return has_font(p_name, p_theme_type);
+			} else {
+				return has_font_no_default(p_name, p_theme_type);
+			}
 		case DATA_TYPE_FONT_SIZE:
-			return has_font_size(p_name, p_theme_type);
+			if (!variation_map.has(p_theme_type)) {
+				return has_font_size(p_name, p_theme_type);
+			} else {
+				return has_font_size_no_default(p_name, p_theme_type);
+			}
 		case DATA_TYPE_ICON:
 			return has_icon(p_name, p_theme_type);
 		case DATA_TYPE_STYLEBOX:
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index 14ad4ae0fd6a..929fd8ad1240 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -155,6 +155,7 @@ class Theme : public Resource {
 	void set_font(const StringName &p_name, const StringName &p_theme_type, const Ref<Font> &p_font);
 	virtual Ref<Font> get_font(const StringName &p_name, const StringName &p_theme_type) const;
 	bool has_font(const StringName &p_name, const StringName &p_theme_type) const;
+	bool has_font_no_default(const StringName &p_name, const StringName &p_theme_type) const;
 	bool has_font_nocheck(const StringName &p_name, const StringName &p_theme_type) const;
 	void rename_font(const StringName &p_old_name, const StringName &p_name, const StringName &p_theme_type);
 	void clear_font(const StringName &p_name, const StringName &p_theme_type);
@@ -166,6 +167,7 @@ class Theme : public Resource {
 	void set_font_size(const StringName &p_name, const StringName &p_theme_type, int p_font_size);
 	virtual int get_font_size(const StringName &p_name, const StringName &p_theme_type) const;
 	bool has_font_size(const StringName &p_name, const StringName &p_theme_type) const;
+	bool has_font_size_no_default(const StringName &p_name, const StringName &p_theme_type) const;
 	bool has_font_size_nocheck(const StringName &p_name, const StringName &p_theme_type) const;
 	void rename_font_size(const StringName &p_old_name, const StringName &p_name, const StringName &p_theme_type);
 	void clear_font_size(const StringName &p_name, const StringName &p_theme_type);


Test patch: