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();
41 void texture(const std::string &);
47 void set_texture(const Texture2D &);
48 const Texture2D &get_texture() const;
49 void add_glyph(unsigned, float, float, float, float, float, float, float, float, float);
50 float get_default_size() const { return default_size; }
51 float get_ascent() const { return ascent; }
52 float get_descent() const { return descent; }
53 float get_string_width(const std::string &, Codecs::Decoder &) const;
54 void draw_glyph(unsigned);
55 void draw_string(const std::string &, Codecs::Decoder &) const;
56 void draw_string(const std::string &, Codecs::Decoder &, PrimitiveBuilder &) const;
59 float get_string_width(const std::string &str) const
61 typename C::Decoder dec;
62 return get_string_width(str, dec);
65 float get_string_width(const std::string &str) const
66 { return get_string_width<Codecs::Utf8>(str); }
69 void draw_string(const std::string &str) const
71 typename C::Decoder dec;
72 draw_string(str, dec);
75 void draw_string(const std::string &str) const
76 { draw_string<Codecs::Utf8>(str); }
79 void draw_string(const std::string &str, PrimitiveBuilder &pb) const
81 typename C::Decoder dec;
82 draw_string(str, dec, pb);
85 void draw_string(const std::string &str, PrimitiveBuilder &pb) const
86 { return draw_string<Codecs::Utf8>(str, pb); }
91 class Loader: public Msp::DataFile::Loader
95 Glyph &get_object() { return glyph; }
99 void texcoords(float, float, float, float);
109 typedef std::map<unsigned, Glyph> GlyphMap;
111 const Texture2D *tex;
117 void create_glyph_vertices(const Glyph &, VertexBuilder &, float) const;
118 float get_glyph_advance(unsigned) const;