3 This file is part of libmspgl
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
13 #include <msp/datafile/collection.h>
14 #include <msp/strings/utf8.h>
15 #include "vertexarray.h"
20 class PrimitiveBuilder;
26 class Loader: public DataFile::Loader
30 DataFile::Collection *coll;
33 typedef DataFile::Collection Collection;
36 Loader(Font &, DataFile::Collection &);
37 Font &get_object() { return font; }
38 DataFile::Collection &get_collection();
42 void texture_inline();
48 void set_texture(const Texture2D &);
49 const Texture2D &get_texture() const;
50 void add_glyph(unsigned, float, float, float, float, float, float, float, float, float);
51 float get_default_size() const { return default_size; }
52 float get_ascent() const { return ascent; }
53 float get_descent() const { return descent; }
54 float get_string_width(const std::string &, Codecs::Decoder &) const;
55 void draw_glyph(unsigned);
56 void draw_string(const std::string &, Codecs::Decoder &) const;
57 void draw_string(const std::string &, Codecs::Decoder &, PrimitiveBuilder &) const;
60 float get_string_width(const std::string &str) const
62 typename C::Decoder dec;
63 return get_string_width(str, dec);
66 float get_string_width(const std::string &str) const
67 { return get_string_width<Codecs::Utf8>(str); }
70 void draw_string(const std::string &str) const
72 typename C::Decoder dec;
73 draw_string(str, dec);
76 void draw_string(const std::string &str) const
77 { draw_string<Codecs::Utf8>(str); }
80 void draw_string(const std::string &str, PrimitiveBuilder &pb) const
82 typename C::Decoder dec;
83 draw_string(str, dec, pb);
86 void draw_string(const std::string &str, PrimitiveBuilder &pb) const
87 { return draw_string<Codecs::Utf8>(str, pb); }
92 class Loader: public Msp::DataFile::Loader
96 Glyph &get_object() { return glyph; }
100 void texcoords(float, float, float, float);
110 typedef std::map<unsigned, Glyph> GlyphMap;
112 const Texture2D *tex;
119 void create_glyph_vertices(const Glyph &, VertexBuilder &, float) const;
120 float get_glyph_advance(unsigned) const;