Font: add constructor/destructor

This commit is contained in:
Josh Holtrop 2014-06-15 20:37:31 -04:00
parent 07662e0abc
commit 27a167e97d
2 changed files with 17 additions and 0 deletions

View File

@ -3,6 +3,19 @@
namespace jes
{
Font::Font()
{
m_loaded = false;
}
Font::~Font()
{
if (m_loaded)
{
FT_Done_Face(m_face);
}
}
bool Font::load(FT_Library ft, const char * fname, size_t size)
{
if (FT_New_Face(ft, fname, 0, &m_face) != 0)
@ -13,6 +26,7 @@ namespace jes
FT_Set_Pixel_Sizes(m_face, 0, size);
m_loaded = true;
return true;
}
}

View File

@ -10,9 +10,12 @@ namespace jes
class Font
{
public:
Font();
~Font();
bool load(FT_Library ft, const char * fname, size_t size);
protected:
FT_Face m_face;
bool m_loaded;
};
typedef Ref<Font> FontRef;