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;
62 void set_texture(const Texture2D &);
63 const Texture2D &get_texture() const;
64 void add_glyph(const Glyph &);
65 float get_native_size() const { return native_size; }
66 float get_ascent() const { return ascent; }
67 float get_descent() const { return descent; }
69 float get_string_width(const std::string &, StringCodec::Decoder &) const;
72 float get_string_width(const std::string &str) const
74 typename C::Decoder dec;
75 return get_string_width(str, dec);
78 float get_string_width(const std::string &str) const
79 { return get_string_width<StringCodec::Utf8>(str); }
81 /// Draws a string to the framebuffer with Immediate.
82 void draw_string(const std::string &, StringCodec::Decoder &, const Color & = Color()) const;
85 void draw_string(const std::string &str, const Color &color = Color()) const
87 typename C::Decoder dec;
88 draw_string(str, dec, color);
91 void draw_string(const std::string &str, const Color &color = Color()) const
92 { draw_string<StringCodec::Utf8>(str, color); }
94 /** Builds the primitives for a string. The PrimitiveBuilder should be
95 associated with a target that has at least VERTEX2 and TEXCOORD2 components.
96 The texture is not bound, to avoid unnecessary bindings when creating
98 void build_string(const std::string &, StringCodec::Decoder &, PrimitiveBuilder &) const;
101 void build_string(const std::string &str, PrimitiveBuilder &pb) const
103 typename C::Decoder dec;
104 build_string(str, dec, pb);
107 void build_string(const std::string &str, PrimitiveBuilder &pb) const
108 { return build_string<StringCodec::Utf8>(str, pb); }
111 void create_glyph_vertices(const Glyph &, VertexBuilder &) const;
112 float get_glyph_advance(unsigned) const;