Show thumbnail for DynamicFont resource
This commit is contained in:
parent
8ea909f5b6
commit
9eff8b7007
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user