BMFont loading direct support from .fnt files.
This commit is contained in:
parent
1968cc445c
commit
4de84f4c0a
3 changed files with 55 additions and 0 deletions
|
|
@ -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 "";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue