diff options
author | volzhs <volzhs@gmail.com> | 2019-11-27 03:35:44 +0900 |
---|---|---|
committer | volzhs <volzhs@gmail.com> | 2019-11-27 03:35:44 +0900 |
commit | 9eff8b7007f7604904d5ec87728002d5df3e4760 (patch) | |
tree | 49ba6230e3f4ff7c274f0de10683ba7216b8b3d2 /editor/plugins | |
parent | 8ea909f5b69ba30070083c45d17ebf1d125bad7f (diff) |
Show thumbnail for DynamicFont resource
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/editor_preview_plugins.cpp | 18 |
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); |