font.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. /*************************************************************************/
  2. /* font.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "font.h"
  31. #include "core/io/resource_loader.h"
  32. #include "core/method_bind_ext.gen.inc"
  33. #include "core/os/file_access.h"
  34. void Font::draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, float p_width, const String &p_text, const Color &p_modulate, const Color &p_outline_modulate) const {
  35. float length = get_string_size(p_text).width;
  36. if (length >= p_width) {
  37. draw(p_canvas_item, p_pos, p_text, p_modulate, p_width, p_outline_modulate);
  38. return;
  39. }
  40. float ofs = 0.f;
  41. switch (p_align) {
  42. case HALIGN_LEFT: {
  43. ofs = 0;
  44. } break;
  45. case HALIGN_CENTER: {
  46. ofs = Math::floor((p_width - length) / 2.0);
  47. } break;
  48. case HALIGN_RIGHT: {
  49. ofs = p_width - length;
  50. } break;
  51. default: {
  52. ERR_PRINT("Unknown halignment type");
  53. } break;
  54. }
  55. draw(p_canvas_item, p_pos + Point2(ofs, 0), p_text, p_modulate, p_width, p_outline_modulate);
  56. }
  57. void Font::draw(RID p_canvas_item, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w, const Color &p_outline_modulate) const {
  58. Vector2 ofs;
  59. int chars_drawn = 0;
  60. bool with_outline = has_outline();
  61. for (int i = 0; i < p_text.length(); i++) {
  62. int width = get_char_size(p_text[i]).width;
  63. if (p_clip_w >= 0 && (ofs.x + width) > p_clip_w)
  64. break; //clip
  65. ofs.x += draw_char(p_canvas_item, p_pos + ofs, p_text[i], p_text[i + 1], with_outline ? p_outline_modulate : p_modulate, with_outline);
  66. ++chars_drawn;
  67. }
  68. if (has_outline()) {
  69. ofs = Vector2(0, 0);
  70. for (int i = 0; i < chars_drawn; i++) {
  71. ofs.x += draw_char(p_canvas_item, p_pos + ofs, p_text[i], p_text[i + 1], p_modulate, false);
  72. }
  73. }
  74. }
  75. void Font::update_changes() {
  76. emit_changed();
  77. }
  78. void Font::_bind_methods() {
  79. ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "string", "modulate", "clip_w", "outline_modulate"), &Font::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(-1), DEFVAL(Color(1, 1, 1)));
  80. ClassDB::bind_method(D_METHOD("get_ascent"), &Font::get_ascent);
  81. ClassDB::bind_method(D_METHOD("get_descent"), &Font::get_descent);
  82. ClassDB::bind_method(D_METHOD("get_height"), &Font::get_height);
  83. ClassDB::bind_method(D_METHOD("is_distance_field_hint"), &Font::is_distance_field_hint);
  84. ClassDB::bind_method(D_METHOD("get_string_size", "string"), &Font::get_string_size);
  85. ClassDB::bind_method(D_METHOD("has_outline"), &Font::has_outline);
  86. ClassDB::bind_method(D_METHOD("draw_char", "canvas_item", "position", "char", "next", "modulate", "outline"), &Font::draw_char, DEFVAL(-1), DEFVAL(Color(1, 1, 1)), DEFVAL(false));
  87. ClassDB::bind_method(D_METHOD("update_changes"), &Font::update_changes);
  88. }
  89. Font::Font() {
  90. }
  91. /////////////////////////////////////////////////////////////////
  92. void BitmapFont::_set_chars(const PoolVector<int> &p_chars) {
  93. int len = p_chars.size();
  94. //char 1 charsize 1 texture, 4 rect, 2 align, advance 1
  95. ERR_FAIL_COND(len % 9);
  96. if (!len)
  97. return; //none to do
  98. int chars = len / 9;
  99. PoolVector<int>::Read r = p_chars.read();
  100. for (int i = 0; i < chars; i++) {
  101. const int *data = &r[i * 9];
  102. add_char(data[0], data[1], Rect2(data[2], data[3], data[4], data[5]), Size2(data[6], data[7]), data[8]);
  103. }
  104. }
  105. PoolVector<int> BitmapFont::_get_chars() const {
  106. PoolVector<int> chars;
  107. const CharType *key = NULL;
  108. while ((key = char_map.next(key))) {
  109. const Character *c = char_map.getptr(*key);
  110. chars.push_back(*key);
  111. chars.push_back(c->texture_idx);
  112. chars.push_back(c->rect.position.x);
  113. chars.push_back(c->rect.position.y);
  114. chars.push_back(c->rect.size.x);
  115. chars.push_back(c->rect.size.y);
  116. chars.push_back(c->h_align);
  117. chars.push_back(c->v_align);
  118. chars.push_back(c->advance);
  119. }
  120. return chars;
  121. }
  122. void BitmapFont::_set_kernings(const PoolVector<int> &p_kernings) {
  123. int len = p_kernings.size();
  124. ERR_FAIL_COND(len % 3);
  125. if (!len)
  126. return;
  127. PoolVector<int>::Read r = p_kernings.read();
  128. for (int i = 0; i < len / 3; i++) {
  129. const int *data = &r[i * 3];
  130. add_kerning_pair(data[0], data[1], data[2]);
  131. }
  132. }
  133. PoolVector<int> BitmapFont::_get_kernings() const {
  134. PoolVector<int> kernings;
  135. for (Map<KerningPairKey, int>::Element *E = kerning_map.front(); E; E = E->next()) {
  136. kernings.push_back(E->key().A);
  137. kernings.push_back(E->key().B);
  138. kernings.push_back(E->get());
  139. }
  140. return kernings;
  141. }
  142. void BitmapFont::_set_textures(const Vector<Variant> &p_textures) {
  143. textures.clear();
  144. for (int i = 0; i < p_textures.size(); i++) {
  145. Ref<Texture> tex = p_textures[i];
  146. ERR_CONTINUE(!tex.is_valid());
  147. add_texture(tex);
  148. }
  149. }
  150. Vector<Variant> BitmapFont::_get_textures() const {
  151. Vector<Variant> rtextures;
  152. for (int i = 0; i < textures.size(); i++)
  153. rtextures.push_back(textures[i].get_ref_ptr());
  154. return rtextures;
  155. }
  156. Error BitmapFont::create_from_fnt(const String &p_file) {
  157. //fnt format used by angelcode bmfont
  158. //http://www.angelcode.com/products/bmfont/
  159. FileAccess *f = FileAccess::open(p_file, FileAccess::READ);
  160. if (!f) {
  161. ERR_EXPLAIN("Can't open font: " + p_file);
  162. ERR_FAIL_V(ERR_FILE_NOT_FOUND);
  163. }
  164. clear();
  165. while (true) {
  166. String line = f->get_line();
  167. int delimiter = line.find(" ");
  168. String type = line.substr(0, delimiter);
  169. int pos = delimiter + 1;
  170. Map<String, String> keys;
  171. while (pos < line.size() && line[pos] == ' ')
  172. pos++;
  173. while (pos < line.size()) {
  174. int eq = line.find("=", pos);
  175. if (eq == -1)
  176. break;
  177. String key = line.substr(pos, eq - pos);
  178. int end = -1;
  179. String value;
  180. if (line[eq + 1] == '"') {
  181. end = line.find("\"", eq + 2);
  182. if (end == -1)
  183. break;
  184. value = line.substr(eq + 2, end - 1 - eq - 1);
  185. pos = end + 1;
  186. } else {
  187. end = line.find(" ", eq + 1);
  188. if (end == -1)
  189. end = line.size();
  190. value = line.substr(eq + 1, end - eq);
  191. pos = end;
  192. }
  193. while (pos < line.size() && line[pos] == ' ')
  194. pos++;
  195. keys[key] = value;
  196. }
  197. if (type == "info") {
  198. if (keys.has("face"))
  199. set_name(keys["face"]);
  200. /*
  201. if (keys.has("size"))
  202. font->set_height(keys["size"].to_int());
  203. */
  204. } else if (type == "common") {
  205. if (keys.has("lineHeight"))
  206. set_height(keys["lineHeight"].to_int());
  207. if (keys.has("base"))
  208. set_ascent(keys["base"].to_int());
  209. } else if (type == "page") {
  210. if (keys.has("file")) {
  211. String base_dir = p_file.get_base_dir();
  212. String file = base_dir.plus_file(keys["file"]);
  213. Ref<Texture> tex = ResourceLoader::load(file);
  214. if (tex.is_null()) {
  215. ERR_PRINT("Can't load font texture!");
  216. } else {
  217. add_texture(tex);
  218. }
  219. }
  220. } else if (type == "char") {
  221. CharType idx = 0;
  222. if (keys.has("id"))
  223. idx = keys["id"].to_int();
  224. Rect2 rect;
  225. if (keys.has("x"))
  226. rect.position.x = keys["x"].to_int();
  227. if (keys.has("y"))
  228. rect.position.y = keys["y"].to_int();
  229. if (keys.has("width"))
  230. rect.size.width = keys["width"].to_int();
  231. if (keys.has("height"))
  232. rect.size.height = keys["height"].to_int();
  233. Point2 ofs;
  234. if (keys.has("xoffset"))
  235. ofs.x = keys["xoffset"].to_int();
  236. if (keys.has("yoffset"))
  237. ofs.y = keys["yoffset"].to_int();
  238. int texture = 0;
  239. if (keys.has("page"))
  240. texture = keys["page"].to_int();
  241. int advance = -1;
  242. if (keys.has("xadvance"))
  243. advance = keys["xadvance"].to_int();
  244. add_char(idx, texture, rect, ofs, advance);
  245. } else if (type == "kerning") {
  246. CharType first = 0, second = 0;
  247. int k = 0;
  248. if (keys.has("first"))
  249. first = keys["first"].to_int();
  250. if (keys.has("second"))
  251. second = keys["second"].to_int();
  252. if (keys.has("amount"))
  253. k = keys["amount"].to_int();
  254. add_kerning_pair(first, second, -k);
  255. }
  256. if (f->eof_reached())
  257. break;
  258. }
  259. memdelete(f);
  260. return OK;
  261. }
  262. void BitmapFont::set_height(float p_height) {
  263. height = p_height;
  264. }
  265. float BitmapFont::get_height() const {
  266. return height;
  267. }
  268. void BitmapFont::set_ascent(float p_ascent) {
  269. ascent = p_ascent;
  270. }
  271. float BitmapFont::get_ascent() const {
  272. return ascent;
  273. }
  274. float BitmapFont::get_descent() const {
  275. return height - ascent;
  276. }
  277. void BitmapFont::add_texture(const Ref<Texture> &p_texture) {
  278. ERR_FAIL_COND(p_texture.is_null());
  279. textures.push_back(p_texture);
  280. }
  281. int BitmapFont::get_texture_count() const {
  282. return textures.size();
  283. };
  284. Ref<Texture> BitmapFont::get_texture(int p_idx) const {
  285. ERR_FAIL_INDEX_V(p_idx, textures.size(), Ref<Texture>());
  286. return textures[p_idx];
  287. };
  288. int BitmapFont::get_character_count() const {
  289. return char_map.size();
  290. };
  291. Vector<CharType> BitmapFont::get_char_keys() const {
  292. Vector<CharType> chars;
  293. chars.resize(char_map.size());
  294. const CharType *ct = NULL;
  295. int count = 0;
  296. while ((ct = char_map.next(ct))) {
  297. chars.write[count++] = *ct;
  298. };
  299. return chars;
  300. };
  301. BitmapFont::Character BitmapFont::get_character(CharType p_char) const {
  302. if (!char_map.has(p_char)) {
  303. ERR_FAIL_V(Character());
  304. };
  305. return char_map[p_char];
  306. };
  307. void BitmapFont::add_char(CharType p_char, int p_texture_idx, const Rect2 &p_rect, const Size2 &p_align, float p_advance) {
  308. if (p_advance < 0)
  309. p_advance = p_rect.size.width;
  310. Character c;
  311. c.rect = p_rect;
  312. c.texture_idx = p_texture_idx;
  313. c.v_align = p_align.y;
  314. c.advance = p_advance;
  315. c.h_align = p_align.x;
  316. char_map[p_char] = c;
  317. }
  318. void BitmapFont::add_kerning_pair(CharType p_A, CharType p_B, int p_kerning) {
  319. KerningPairKey kpk;
  320. kpk.A = p_A;
  321. kpk.B = p_B;
  322. if (p_kerning == 0 && kerning_map.has(kpk)) {
  323. kerning_map.erase(kpk);
  324. } else {
  325. kerning_map[kpk] = p_kerning;
  326. }
  327. }
  328. Vector<BitmapFont::KerningPairKey> BitmapFont::get_kerning_pair_keys() const {
  329. Vector<BitmapFont::KerningPairKey> ret;
  330. ret.resize(kerning_map.size());
  331. int i = 0;
  332. for (Map<KerningPairKey, int>::Element *E = kerning_map.front(); E; E = E->next()) {
  333. ret.write[i++] = E->key();
  334. }
  335. return ret;
  336. }
  337. int BitmapFont::get_kerning_pair(CharType p_A, CharType p_B) const {
  338. KerningPairKey kpk;
  339. kpk.A = p_A;
  340. kpk.B = p_B;
  341. const Map<KerningPairKey, int>::Element *E = kerning_map.find(kpk);
  342. if (E)
  343. return E->get();
  344. return 0;
  345. }
  346. void BitmapFont::set_distance_field_hint(bool p_distance_field) {
  347. distance_field_hint = p_distance_field;
  348. emit_changed();
  349. }
  350. bool BitmapFont::is_distance_field_hint() const {
  351. return distance_field_hint;
  352. }
  353. void BitmapFont::clear() {
  354. height = 1;
  355. ascent = 0;
  356. char_map.clear();
  357. textures.clear();
  358. kerning_map.clear();
  359. distance_field_hint = false;
  360. }
  361. Size2 Font::get_string_size(const String &p_string) const {
  362. float w = 0;
  363. int l = p_string.length();
  364. if (l == 0)
  365. return Size2(0, get_height());
  366. const CharType *sptr = &p_string[0];
  367. for (int i = 0; i < l; i++) {
  368. w += get_char_size(sptr[i], sptr[i + 1]).width;
  369. }
  370. return Size2(w, get_height());
  371. }
  372. void BitmapFont::set_fallback(const Ref<BitmapFont> &p_fallback) {
  373. fallback = p_fallback;
  374. }
  375. Ref<BitmapFont> BitmapFont::get_fallback() const {
  376. return fallback;
  377. }
  378. float BitmapFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, bool p_outline) const {
  379. const Character *c = char_map.getptr(p_char);
  380. if (!c) {
  381. if (fallback.is_valid())
  382. return fallback->draw_char(p_canvas_item, p_pos, p_char, p_next, p_modulate, p_outline);
  383. return 0;
  384. }
  385. ERR_FAIL_COND_V(c->texture_idx < -1 || c->texture_idx >= textures.size(), 0);
  386. if (!p_outline && c->texture_idx != -1) {
  387. Point2 cpos = p_pos;
  388. cpos.x += c->h_align;
  389. cpos.y -= ascent;
  390. cpos.y += c->v_align;
  391. VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate, false, RID(), false);
  392. }
  393. return get_char_size(p_char, p_next).width;
  394. }
  395. Size2 BitmapFont::get_char_size(CharType p_char, CharType p_next) const {
  396. const Character *c = char_map.getptr(p_char);
  397. if (!c) {
  398. if (fallback.is_valid())
  399. return fallback->get_char_size(p_char, p_next);
  400. return Size2();
  401. }
  402. Size2 ret(c->advance, c->rect.size.y);
  403. if (p_next) {
  404. KerningPairKey kpk;
  405. kpk.A = p_char;
  406. kpk.B = p_next;
  407. const Map<KerningPairKey, int>::Element *E = kerning_map.find(kpk);
  408. if (E) {
  409. ret.width -= E->get();
  410. }
  411. }
  412. return ret;
  413. }
  414. void BitmapFont::_bind_methods() {
  415. ClassDB::bind_method(D_METHOD("create_from_fnt", "path"), &BitmapFont::create_from_fnt);
  416. ClassDB::bind_method(D_METHOD("set_height", "px"), &BitmapFont::set_height);
  417. ClassDB::bind_method(D_METHOD("set_ascent", "px"), &BitmapFont::set_ascent);
  418. ClassDB::bind_method(D_METHOD("add_kerning_pair", "char_a", "char_b", "kerning"), &BitmapFont::add_kerning_pair);
  419. ClassDB::bind_method(D_METHOD("get_kerning_pair", "char_a", "char_b"), &BitmapFont::get_kerning_pair);
  420. ClassDB::bind_method(D_METHOD("add_texture", "texture"), &BitmapFont::add_texture);
  421. ClassDB::bind_method(D_METHOD("add_char", "character", "texture", "rect", "align", "advance"), &BitmapFont::add_char, DEFVAL(Point2()), DEFVAL(-1));
  422. ClassDB::bind_method(D_METHOD("get_texture_count"), &BitmapFont::get_texture_count);
  423. ClassDB::bind_method(D_METHOD("get_texture", "idx"), &BitmapFont::get_texture);
  424. ClassDB::bind_method(D_METHOD("get_char_size", "char", "next"), &BitmapFont::get_char_size, DEFVAL(0));
  425. ClassDB::bind_method(D_METHOD("set_distance_field_hint", "enable"), &BitmapFont::set_distance_field_hint);
  426. ClassDB::bind_method(D_METHOD("clear"), &BitmapFont::clear);
  427. ClassDB::bind_method(D_METHOD("_set_chars"), &BitmapFont::_set_chars);
  428. ClassDB::bind_method(D_METHOD("_get_chars"), &BitmapFont::_get_chars);
  429. ClassDB::bind_method(D_METHOD("_set_kernings"), &BitmapFont::_set_kernings);
  430. ClassDB::bind_method(D_METHOD("_get_kernings"), &BitmapFont::_get_kernings);
  431. ClassDB::bind_method(D_METHOD("_set_textures"), &BitmapFont::_set_textures);
  432. ClassDB::bind_method(D_METHOD("_get_textures"), &BitmapFont::_get_textures);
  433. ClassDB::bind_method(D_METHOD("set_fallback", "fallback"), &BitmapFont::set_fallback);
  434. ClassDB::bind_method(D_METHOD("get_fallback"), &BitmapFont::get_fallback);
  435. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_textures", "_get_textures");
  436. ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "chars", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_chars", "_get_chars");
  437. ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "kernings", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_kernings", "_get_kernings");
  438. ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "-1024,1024,1"), "set_height", "get_height");
  439. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ascent", PROPERTY_HINT_RANGE, "-1024,1024,1"), "set_ascent", "get_ascent");
  440. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "distance_field"), "set_distance_field_hint", "is_distance_field_hint");
  441. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE, "BitmapFont"), "set_fallback", "get_fallback");
  442. }
  443. BitmapFont::BitmapFont() {
  444. clear();
  445. }
  446. BitmapFont::~BitmapFont() {
  447. clear();
  448. }
  449. ////////////
  450. RES ResourceFormatLoaderBMFont::load(const String &p_path, const String &p_original_path, Error *r_error) {
  451. if (r_error)
  452. *r_error = ERR_FILE_CANT_OPEN;
  453. Ref<BitmapFont> font;
  454. font.instance();
  455. Error err = font->create_from_fnt(p_path);
  456. if (err) {
  457. if (r_error)
  458. *r_error = err;
  459. return RES();
  460. }
  461. return font;
  462. }
  463. void ResourceFormatLoaderBMFont::get_recognized_extensions(List<String> *p_extensions) const {
  464. p_extensions->push_back("fnt");
  465. }
  466. bool ResourceFormatLoaderBMFont::handles_type(const String &p_type) const {
  467. return (p_type == "BitmapFont");
  468. }
  469. String ResourceFormatLoaderBMFont::get_resource_type(const String &p_path) const {
  470. String el = p_path.get_extension().to_lower();
  471. if (el == "fnt")
  472. return "BitmapFont";
  473. return "";
  474. }