unsigned line_spacing = static_cast<unsigned>(font_size*6/5);
const Sides &margin = part.get_margin();
- unsigned vmargin = margin.top+margin.bottom+line_height-line_spacing;
- unsigned n_lines = min<unsigned>(lines.size(), max((max(parent.h, vmargin)-vmargin)/line_spacing, 1U));
+ unsigned vmargin = margin.top+margin.bottom;
+ unsigned free_height = max(parent.h, vmargin)-vmargin+line_spacing-line_height;
+ unsigned n_lines = min<unsigned>(lines.size(), max(free_height/line_spacing, 1U));
if(fit_height)
*fit_height = line_height+(n_lines-1)*line_spacing;