+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());