summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/plugins/editor_preview_plugins.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 007ce58bd7..204562ac38 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/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);