From: Mikko Rasa Date: Wed, 28 Nov 2012 20:08:16 +0000 (+0200) Subject: Change Font::add_glyph to take a glyph struct X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=1ddd5b2a0c4ab104d90db427af0f24991fc40580 Change Font::add_glyph to take a glyph struct Did I seriously think that a function with 10 parameters was a good idea? --- diff --git a/source/font.cpp b/source/font.cpp index 61534f0b..53e3bd62 100644 --- a/source/font.cpp +++ b/source/font.cpp @@ -1,3 +1,4 @@ +#include #include #include "bindable.h" #include "gl.h" @@ -30,20 +31,9 @@ const Texture2D &Font::get_texture() const return *texture; } -void Font::add_glyph(unsigned code, float x1, float y1, float x2, float y2, float w, float h, float ox, float oy, float adv) -{ - Glyph glyph; - glyph.code = code; - glyph.x1 = x1; - glyph.y1 = y1; - glyph.x2 = x2; - glyph.y2 = y2; - glyph.w = w; - glyph.h = h; - glyph.off_x = ox; - glyph.off_y = oy; - glyph.advance = adv; - glyphs.insert(GlyphMap::value_type(code, glyph)); +void Font::add_glyph(const Glyph &g) +{ + insert_unique(glyphs, g.code, g); } float Font::get_string_width(const string &str, StringCodec::Decoder &dec) const diff --git a/source/font.h b/source/font.h index a6873aac..6f8f35ff 100644 --- a/source/font.h +++ b/source/font.h @@ -29,7 +29,6 @@ public: void texture_ref(const std::string &); }; -private: struct Glyph { class Loader: public Msp::DataFile::ObjectLoader @@ -48,6 +47,7 @@ private: float advance; }; +private: typedef std::map GlyphMap; RefPtr texture; @@ -61,7 +61,7 @@ public: void set_texture(const Texture2D &); const Texture2D &get_texture() const; - void add_glyph(unsigned, float, float, float, float, float, float, float, float, float); + void add_glyph(const Glyph &); float get_native_size() const { return native_size; } float get_ascent() const { return ascent; } float get_descent() const { return descent; }