3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
13 #include <msp/datafile/objectloader.h>
14 #include <msp/strings/utf8.h>
15 #include "vertexarray.h"
20 class PrimitiveBuilder;
26 class Loader: public DataFile::CollectionObjectLoader<Font>
30 Loader(Font &, Collection &);
34 void texture_inline();
40 void set_texture(const Texture2D &);
41 const Texture2D &get_texture() const;
42 void add_glyph(unsigned, float, float, float, float, float, float, float, float, float);
43 float get_default_size() const { return default_size; }
44 float get_ascent() const { return ascent; }
45 float get_descent() const { return descent; }
46 float get_string_width(const std::string &, Codecs::Decoder &) const;
47 void draw_glyph(unsigned);
48 void draw_string(const std::string &, Codecs::Decoder &) const;
49 void draw_string(const std::string &, Codecs::Decoder &, PrimitiveBuilder &) const;
52 float get_string_width(const std::string &str) const
54 typename C::Decoder dec;
55 return get_string_width(str, dec);
58 float get_string_width(const std::string &str) const
59 { return get_string_width<Codecs::Utf8>(str); }
62 void draw_string(const std::string &str) const
64 typename C::Decoder dec;
65 draw_string(str, dec);
68 void draw_string(const std::string &str) const
69 { draw_string<Codecs::Utf8>(str); }
72 void draw_string(const std::string &str, PrimitiveBuilder &pb) const
74 typename C::Decoder dec;
75 draw_string(str, dec, pb);
78 void draw_string(const std::string &str, PrimitiveBuilder &pb) const
79 { return draw_string<Codecs::Utf8>(str, pb); }
84 class Loader: public Msp::DataFile::ObjectLoader<Glyph>
89 void texcoords(float, float, float, float);
99 typedef std::map<unsigned, Glyph> GlyphMap;
101 const Texture2D *tex;
108 void create_glyph_vertices(const Glyph &, VertexBuilder &, float) const;
109 float get_glyph_advance(unsigned) const;