void Font::AdjustFont(std::string file) { if(exists(file.c_str()) == false) { throw FileNotFoundException(file); } _file = file; if(_font != font) destroy_font(_font); _font = nullptr; _font = load_bitmap_font(file.c_str(), nullptr, nullptr); _height = 0; if(_font) { _height = text_height(_font); } }
/* load_font: * Loads a font from disk. Will try to load a font from a bitmap if all else * fails. */ FONT *load_font(AL_CONST char *filename, RGB *pal, void *param) { char tmp[32], *aext; FONT_TYPE_INFO *iter; ASSERT(filename); aext = uconvert_toascii(get_extension(filename), tmp); for (iter = font_type_list; iter; iter = iter->next) { if (stricmp(iter->ext, aext) == 0) { if (iter->load) return iter->load(filename, pal, param); return NULL; } } /* Try to load the file as a bitmap image and grab the font from there */ return load_bitmap_font(filename, pal, param); }
A2DE_BEGIN Font::Font(std::string file) : _file(file), _font(load_bitmap_font(_file.c_str(), nullptr, nullptr)), _height(0) { if(_font) _height = text_height(_font); }