diff options
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/font.cpp | 39 | ||||
-rw-r--r-- | scene/resources/font.h | 8 |
2 files changed, 47 insertions, 0 deletions
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 026bcea270..6fc5778dd8 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -596,3 +596,42 @@ BitmapFont::~BitmapFont() { clear(); } + +//////////// + +RES ResourceFormatLoaderBMFont::load(const String &p_path, const String &p_original_path, Error *r_error) { + + if (r_error) + *r_error = ERR_FILE_CANT_OPEN; + + Ref<BitmapFont> font; + font.instance(); + + Error err = font->create_from_fnt(p_path); + + if (err) { + if (r_error) + *r_error = err; + return RES(); + } + + return font; +} + +void ResourceFormatLoaderBMFont::get_recognized_extensions(List<String> *p_extensions) const { + + p_extensions->push_back("fnt"); +} + +bool ResourceFormatLoaderBMFont::handles_type(const String &p_type) const { + + return (p_type == "BitmapFont"); +} + +String ResourceFormatLoaderBMFont::get_resource_type(const String &p_path) const { + + String el = p_path.get_extension().to_lower(); + if (el == "fnt") + return "BitmapFont"; + return ""; +} diff --git a/scene/resources/font.h b/scene/resources/font.h index 3f228ca002..ae08890be3 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -159,4 +159,12 @@ public: ~BitmapFont(); }; +class ResourceFormatLoaderBMFont : public ResourceFormatLoader { +public: + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); + virtual void get_recognized_extensions(List<String> *p_extensions) const; + virtual bool handles_type(const String &p_type) const; + virtual String get_resource_type(const String &p_path) const; +}; + #endif |