From cd3dfdaf18506c3ff2c41d8d94c7ec9fe12fbef5 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 2 Jan 2016 14:53:48 -0300 Subject: [PATCH] Support BMFont in font editor plugin, closes #2204 --- .../io_plugins/editor_font_import_plugin.cpp | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 7bb2b5b77db..9b4ca246e76 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -621,6 +621,7 @@ public: source->get_file_dialog()->set_mode(EditorFileDialog::MODE_OPEN_FILE); source->get_file_dialog()->add_filter("*.ttf;TrueType"); source->get_file_dialog()->add_filter("*.otf;OpenType"); + source->get_file_dialog()->add_filter("*.fnt;BMFont"); source->get_line_edit()->connect("text_entered",this,"_src_changed"); vbl->add_margin_child("Source Font:",source); @@ -876,10 +877,31 @@ static unsigned char get_SDF_radial( Ref EditorFontImportPlugin::generate_font(const Ref& p_from, const String &p_existing) { + + Ref from = p_from; ERR_FAIL_COND_V(from->get_source_count()!=1,Ref()); String src_path = EditorImportPlugin::expand_source_path(from->get_source_path(0)); + + if (src_path.extension().to_lower()=="fnt") { + + if (ResourceLoader::load(src_path).is_valid()) { + EditorNode::get_singleton()->show_warning("Path: "+src_path+"\nIs a Godot font file, please supply a BMFont type file instead."); + return Ref(); + } + + Ref font; + font.instance(); + Error err = font->create_from_fnt(src_path); + if (err) { + EditorNode::get_singleton()->show_warning("Path: "+src_path+"\nFailed opening as BMFont file."); + return Ref(); + } + + return font; + } + int size = from->get_option("font/size"); #ifdef FREETYPE_ENABLED