7 #include "objectinstance.h"
13 Creates a Mesh and an Object for rendering text.
15 The mesh is created with a font size of 1 unit. Set the Text's model matrix to
16 scale it to the desired size.
18 If you derive from Text to customize it, make sure you call Text::setup_render
19 or otherwise set the appropriate texture to the Renderer.
21 class Text: public ObjectInstance
44 float horz_align = 0.0f;
45 float vert_offset = 0.0f;
49 Text(const Font &, const Technique * = 0, Tag = Tag());
51 const Mesh *get_mesh() const { return &mesh; }
53 /** Sets technique to render with, along with the texture slot to use for
54 the font texture. If no texture slot is specified, heuristics are used to
55 choose a suitable one. */
56 void set_technique(const Technique *, Tag = Tag());
58 const Technique *get_technique() const { return object.get_technique(); }
60 /** Sets the string to be displayed, with an explicit character encoding. */
61 void set_text(const std::string &, StringCodec::Decoder &);
64 void set_text(const std::string &t)
66 typename C::Decoder dec;
70 /** Sets the string to be displayed, with UTF-8 encoding. */
71 void set_text(const std::string &t)
72 { set_text<StringCodec::Utf8>(t); }
74 /** Clears any previous contents. */
77 /** Sets horizontal and vertical alignment with predefined anchors. */
78 void set_alignment(HorizontalAlign, VerticalAlign = BASELINE);
80 /** Sets horizontal and vertical alignment. 0.0 means left or baseline,
81 1.0 means right or top. */
82 void set_alignment(float, float = 0.0f);
84 float get_width() const { return width; }
86 virtual void setup_render(Renderer &, Tag) const;
88 DEPRECATED operator const Object &() const { return object; }