Procházet zdrojové kódy

Show thumbnail for DynamicFont resource

volzhs před 5 roky
rodič
revize
9eff8b7007
1 změnil soubory, kde provedl 11 přidání a 7 odebrání
  1. 11 7
      editor/plugins/editor_preview_plugins.cpp

+ 11 - 7
editor/plugins/editor_preview_plugins.cpp

@@ -827,19 +827,23 @@ void EditorFontPreviewPlugin::_bind_methods() {
 
 bool EditorFontPreviewPlugin::handles(const String &p_type) const {
 
-	return ClassDB::is_parent_class(p_type, "DynamicFontData");
+	return ClassDB::is_parent_class(p_type, "DynamicFontData") || ClassDB::is_parent_class(p_type, "DynamicFont");
 }
 
 Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, const Size2 &p_size) const {
 
-	Ref<DynamicFontData> SampledFont;
-	SampledFont.instance();
-	SampledFont->set_font_path(p_path);
-
+	RES res = ResourceLoader::load(p_path);
 	Ref<DynamicFont> sampled_font;
-	sampled_font.instance();
+	if (res->is_class("DynamicFont")) {
+		sampled_font = res->duplicate();
+		if (sampled_font->get_outline_color() == Color(1, 1, 1, 1)) {
+			sampled_font->set_outline_color(Color(0, 0, 0, 1));
+		}
+	} else if (res->is_class("DynamicFontData")) {
+		sampled_font.instance();
+		sampled_font->set_font_data(res);
+	}
 	sampled_font->set_size(50);
-	sampled_font->set_font_data(SampledFont);
 
 	String sampled_text = "Abg";
 	Vector2 size = sampled_font->get_string_size(sampled_text);