+ start = newline+1;
+ }
+}
+
+template<typename T, void (Text::*func)(unsigned, const Geometry &, T &) const>
+void Text::process_lines(const Part &part, const Geometry &parent, unsigned first_row, T &data) const
+{
+ const GL::Font *font = style->get_font();
+ float font_size = font->get_default_size();
+ unsigned line_height = static_cast<unsigned>((font->get_ascent()-font->get_descent())*font_size);
+ unsigned line_spacing = static_cast<unsigned>(font_size*6/5);
+ unsigned height = line_height+(lines.size()-1)*line_spacing;
+ int y_offset = static_cast<int>(-font->get_descent()*font_size);
+
+ const Sides &margin = part.get_margin();
+ unsigned n_lines = max(min(lines.size(), (parent.h-margin.top-margin.bottom)/line_spacing), 1U);
+ first_row = min(first_row, lines.size()-n_lines);
+
+ for(unsigned i=0; i<n_lines; ++i)
+ {
+ const Line &line = lines[first_row+i];
+
+ Geometry rgeom;
+ rgeom.w = line.width;
+ rgeom.h = height;
+ rgeom.y = (n_lines-1-i)*line_spacing+y_offset;
+ part.get_alignment().apply(rgeom, parent, part.get_margin());
+
+ (this->*func)(first_row+i, rgeom, data);
+ }
+}
+
+void Text::render_line(unsigned i, const Geometry &rgeom, RenderData &data) const
+{
+ const Line &line = lines[i];
+ const GL::Font *font = style->get_font();
+
+ GL::PushMatrix _pushm;
+ GL::translate(rgeom.x, rgeom.y, 0);
+ GL::scale_uniform(font->get_default_size());
+
+ font->draw_string(text.substr(line.start, line.length), *data.bld);
+}
+
+void Text::coords_to_geom_line(unsigned i, const Geometry &rgeom, CoordsToGeomData &data) const
+{
+ if(i==data.row)
+ {
+ const Line &line = lines[i];
+ const GL::Font *font = style->get_font();
+
+ data.result = rgeom;
+ data.result.x += static_cast<unsigned>(font->get_string_width(text.substr(line.start, data.col))*font->get_default_size());