X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuilders%2Ffont.cpp;h=dfa6bf9cf953685c2472c29b29788447e53e6642;hb=e9a898f315b5d1396f196d785913a283c30940f2;hp=5990c57d7223771410edadcfb69a9df13ea39fe0;hpb=7aaec9a70b8d7733429bec043f8e33e02956f266;p=libs%2Fgl.git diff --git a/source/builders/font.cpp b/source/builders/font.cpp index 5990c57d..dfa6bf9c 100644 --- a/source/builders/font.cpp +++ b/source/builders/font.cpp @@ -1,6 +1,6 @@ #include #include -#include "bindable.h" +#include #include "gl.h" #include "font.h" #include "primitivebuilder.h" @@ -26,7 +26,6 @@ Font::~Font() void Font::set_texture(const Texture2D &t) { texture = &t; - texture.keep(); } const Texture2D &Font::get_texture() const @@ -51,7 +50,7 @@ float Font::get_string_width(const string &str, StringCodec::Decoder &dec) const float x = 0; unsigned prev = 0; - for(string::const_iterator i=str.begin(); i!=str.end();) + for(auto i=str.begin(); i!=str.end();) { unsigned c = dec.decode_char(str, i); if(prev) @@ -69,7 +68,7 @@ void Font::build_string(const string &str, StringCodec::Decoder &dec, PrimitiveB unsigned prev = 0; unsigned next = 0; - for(string::const_iterator i=str.begin(); (next || i!=str.end());) + for(auto i=str.begin(); (next || i!=str.end());) { unsigned c = (next ? next : dec.decode_char(str, i)); next = (i!=str.end() ? dec.decode_char(str, i) : 0); @@ -80,7 +79,7 @@ void Font::build_string(const string &str, StringCodec::Decoder &dec, PrimitiveB next = 0; } - GlyphMap::const_iterator j = glyphs.find(c); + auto j = glyphs.find(c); if(j==glyphs.end()) continue; @@ -108,7 +107,7 @@ void Font::create_glyph_quad(const Glyph &glyph, PrimitiveBuilder &bld) const float Font::get_glyph_advance(unsigned code, unsigned next) const { - GlyphMap::const_iterator i = glyphs.find(code); + auto i = glyphs.find(code); if(i==glyphs.end()) return 0; @@ -116,7 +115,7 @@ float Font::get_glyph_advance(unsigned code, unsigned next) const if(next) { - KerningMap::const_iterator j = kerning.find(CodePair(code, next)); + auto j = kerning.find(CodePair(code, next)); if(j!=kerning.end()) advance += j->second; } @@ -126,7 +125,7 @@ float Font::get_glyph_advance(unsigned code, unsigned next) const unsigned Font::get_ligature(unsigned code, unsigned next) const { - LigatureMap::const_iterator i = ligatures.find(CodePair(code, next)); + auto i = ligatures.find(CodePair(code, next)); return (i!=ligatures.end() ? i->second : 0); } @@ -193,13 +192,13 @@ void Font::Loader::texture() { RefPtr tex = new Texture2D; load_sub(*tex); - obj.texture = tex; + get_collection().add(FS::basename(get_source())+".tex2d", tex.get()); + obj.texture = tex.release(); } void Font::Loader::texture_ref(const string &name) { obj.texture = &get_collection().get(name); - obj.texture.keep(); }