X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Ffont.cpp;h=f82b45d8ac81fe7bb3ac30b7f70be453b2a720b7;hp=766f011a97dc55708b3fb11da395342facfb6a92;hb=652cb91c2b6008c4407c16054085f20bf5888c4d;hpb=05e003962916b3c1b8c0ecfd2d4fb7ce0c2e45ca diff --git a/source/font.cpp b/source/font.cpp index 766f011a..f82b45d8 100644 --- a/source/font.cpp +++ b/source/font.cpp @@ -18,14 +18,25 @@ namespace GL { Font::Font(): tex(0), + own_tex(false), default_size(1), ascent(1), descent(0) { } +Font::~Font() +{ + if(own_tex) + delete tex; +} + void Font::set_texture(const Texture2D &t) { + if(own_tex) + delete tex; + tex=&t; + own_tex=false; } const Texture2D &Font::get_texture() const @@ -140,6 +151,7 @@ void Font::Loader::init() add("ascent", &Font::ascent); add("descent", &Font::descent); add("texture", &Font::tex); + add("texture_inline", &Loader::texture_inline); add("glyph", &Loader::glyph); } @@ -151,6 +163,14 @@ void Font::Loader::glyph(unsigned c) font.glyphs.insert(GlyphMap::value_type(c, gl)); } +void Font::Loader::texture_inline() +{ + RefPtr tex=new Texture2D; + load_sub(*tex); + font.tex=tex.release(); + font.own_tex=true; +} + Font::Glyph::Loader::Loader(Glyph &g): glyph(g)