From 27a167e97db7ee3da16289a3917e0f737162f260 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 15 Jun 2014 20:37:31 -0400 Subject: [PATCH] Font: add constructor/destructor --- src/gui/Font.cc | 14 ++++++++++++++ src/gui/Font.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/gui/Font.cc b/src/gui/Font.cc index 3c0491d..8ce4a1a 100644 --- a/src/gui/Font.cc +++ b/src/gui/Font.cc @@ -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; } } diff --git a/src/gui/Font.h b/src/gui/Font.h index 3dfffa6..a824920 100644 --- a/src/gui/Font.h +++ b/src/gui/Font.h @@ -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 FontRef;