6 #include <msp/datafile/objectloader.h>
7 #include <msp/stringcodec/utf8.h>
8 #include "vertexarray.h"
13 class PrimitiveBuilder;
19 class Loader: public DataFile::CollectionObjectLoader<Font>
23 Loader(Font &, Collection &);
29 void texture_ref(const std::string &);
34 class Loader: public Msp::DataFile::ObjectLoader<Glyph>
39 void texcoords(float, float, float, float);
51 typedef std::map<unsigned, Glyph> GlyphMap;
53 RefPtr<const Texture2D> texture;
63 void set_texture(const Texture2D &);
64 const Texture2D &get_texture() const;
65 void add_glyph(const Glyph &);
66 float get_native_size() const { return native_size; }
67 float get_ascent() const { return ascent; }
68 float get_descent() const { return descent; }
70 float get_string_width(const std::string &, StringCodec::Decoder &) const;
73 float get_string_width(const std::string &str) const
75 typename C::Decoder dec;
76 return get_string_width(str, dec);
79 float get_string_width(const std::string &str) const
80 { return get_string_width<StringCodec::Utf8>(str); }
82 /// Draws a string to the framebuffer with Immediate.
83 void draw_string(const std::string &, StringCodec::Decoder &, const Color & = Color()) const;
86 void draw_string(const std::string &str, const Color &color = Color()) const
88 typename C::Decoder dec;
89 draw_string(str, dec, color);
92 void draw_string(const std::string &str, const Color &color = Color()) const
93 { draw_string<StringCodec::Utf8>(str, color); }
95 /** Builds the primitives for a string. The PrimitiveBuilder should be
96 associated with a target that has at least VERTEX2 and TEXCOORD2 components.
97 The texture is not bound, to avoid unnecessary bindings when creating
99 void build_string(const std::string &, StringCodec::Decoder &, PrimitiveBuilder &) const;
102 void build_string(const std::string &str, PrimitiveBuilder &pb) const
104 typename C::Decoder dec;
105 build_string(str, dec, pb);
108 void build_string(const std::string &str, PrimitiveBuilder &pb) const
109 { return build_string<StringCodec::Utf8>(str, pb); }
112 void create_glyph_vertices(const Glyph &, VertexBuilder &) const;
113 float get_glyph_advance(unsigned) const;