From c3b6098d0ca039fed7dc714a64c369e6f6d07e5a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 11 Dec 2007 11:30:48 +0000 Subject: [PATCH] Default to Utf8 instead of direct mapping in Font --- source/font.cpp | 20 -------------------- source/font.h | 11 ++++++++--- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/source/font.cpp b/source/font.cpp index a19a94e5..60090e01 100644 --- a/source/font.cpp +++ b/source/font.cpp @@ -47,16 +47,6 @@ void Font::add_glyph(unsigned code, float x1, float y1, float x2, float y2, floa create_glyph_vertices(glyph, *va_builder); } -float Font::get_string_width(const string &str) const -{ - float x=0; - - for(string::const_iterator i=str.begin(); i!=str.end(); ++i) - x+=get_glyph_advance(static_cast(*i)); - - return x; -} - float Font::get_string_width(const string &str, Codecs::Decoder &dec) const { float x=0; @@ -67,16 +57,6 @@ float Font::get_string_width(const string &str, Codecs::Decoder &dec) const return x; } -void Font::draw_string(const string &str) const -{ - prepare_render(); - - for(string::const_iterator i=str.begin(); i!=str.end(); ++i) - draw_glyph(static_cast(*i)); - - glPopMatrix(); -} - void Font::draw_string(const string &str, Codecs::Decoder &dec) const { prepare_render(); diff --git a/source/font.h b/source/font.h index 3178a4c2..68c035a6 100644 --- a/source/font.h +++ b/source/font.h @@ -11,7 +11,7 @@ Distributed under the LGPL #include #include #include -#include +#include #include "vertexarray.h" namespace Msp { @@ -49,10 +49,8 @@ public: float get_default_size() const { return default_size; } float get_ascent() const { return ascent; } float get_descent() const { return descent; } - float get_string_width(const std::string &) const; float get_string_width(const std::string &, Codecs::Decoder &) const; void draw_glyph(unsigned); - void draw_string(const std::string &) const; void draw_string(const std::string &, Codecs::Decoder &) const; void draw_multiline(const std::string &) const; @@ -63,12 +61,19 @@ public: return get_string_width(str, dec); } + float get_string_width(const std::string &str) const + { return get_string_width(str); } + template void draw_string(const std::string &str) const { typename C::Decoder dec; draw_string(str, dec); } + + void draw_string(const std::string &str) const + { draw_string(str); } + private: struct Glyph { -- 2.45.2