|
|
@@ -35,4 +35,22 @@ std::unordered_map<char, math::vec2> glyph_locations(std::string const & font) {
|
|
|
text_engine::text_engine(std::string const & font,
|
|
|
std::shared_ptr<graphics::manager const> manager)
|
|
|
: font_(font), prototype_(to_object(font_material(font_), *manager)),
|
|
|
- glyphs_(glyph_locations(font_)) {}
|
|
|
+ glyphs_(glyph_locations(font_)) {
|
|
|
+ // TODO (sjaffe): Also needs to be programmatic
|
|
|
+ prototype_.frame.size = make_vector(0.125f, 0.125f);
|
|
|
+}
|
|
|
+
|
|
|
+void text_engine::create_text_cells(std::vector<graphics::object> & out,
|
|
|
+ cell const & in) {
|
|
|
+ std::size_t const old_size = out.size();
|
|
|
+ std::size_t const new_size = in.content.size();
|
|
|
+ if (old_size != new_size) { out.resize(new_size, prototype_); }
|
|
|
+ for (std::size_t i = old_size; i < new_size; ++i) {
|
|
|
+ auto & obj = out[i];
|
|
|
+ obj.location = {in.origin + make_vector(in.size[0] * i, 0.f), in.size};
|
|
|
+ obj.points = obj.location;
|
|
|
+ }
|
|
|
+ for (std::size_t i = 0; i < new_size; ++i) {
|
|
|
+ out[i].frame.origin = glyphs_.find(in.content[i])->second;
|
|
|
+ }
|
|
|
+}
|