X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fbuilders%2Ffont.cpp;h=58b23fe9dac150cefb9f0212c7b7777cba8584a3;hp=7281bf418aba8118ab479abf79778f542cb0fb4f;hb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;hpb=3ac3a51c623271da815c8ee60c484445871753bf diff --git a/source/builders/font.cpp b/source/builders/font.cpp index 7281bf41..58b23fe9 100644 --- a/source/builders/font.cpp +++ b/source/builders/font.cpp @@ -1,8 +1,6 @@ #include #include #include -#include "bindable.h" -#include "gl.h" #include "font.h" #include "primitivebuilder.h" #include "texture2d.h" @@ -12,18 +10,6 @@ using namespace std; namespace Msp { namespace GL { -Font::Font(): - native_size(1), - ascent(1), - descent(0), - cap_height(1), - x_height(0.5) -{ } - -// Avoid synthesizing ~RefPtr in files including font.h -Font::~Font() -{ } - void Font::set_texture(const Texture2D &t) { texture = &t; @@ -51,7 +37,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 +55,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 +66,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 +94,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 +102,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,38 +112,13 @@ 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); } -Font::Glyph::Glyph(): - code(0), - x1(0), - y1(0), - x2(1), - y2(1), - w(1), - h(1), - off_x(0), - off_y(0), - advance(1) -{ } - - -Font::Loader::Loader(Font &f): - DataFile::CollectionObjectLoader(f, 0) -{ - init(); -} - Font::Loader::Loader(Font &f, Collection &c): DataFile::CollectionObjectLoader(f, &c) -{ - init(); -} - -void Font::Loader::init() { add("native_size", &Font::native_size); add("ascent", &Font::ascent);