X-Git-Url: http://git.tdb.fi/?p=libs%2Fgltk.git;a=blobdiff_plain;f=source%2Ftext.cpp;h=45b6567db5c640bcec37e0dfccee877323fde230;hp=1d824e0ddb9ca590f551748921503e626bcdd931;hb=8bc33895d1bb04adcefee405746ef3c21d99a66d;hpb=b3de715986f0e5b6359a2109c27d052c3d9cc27a diff --git a/source/text.cpp b/source/text.cpp index 1d824e0..45b6567 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -123,8 +123,9 @@ unsigned Text::get_visible_lines(const Part &part, const Geometry &parent, unsig unsigned line_spacing = static_cast(font_size*6/5); const Sides &margin = part.get_margin(); - unsigned vmargin = margin.top+margin.bottom+line_height-line_spacing; - unsigned n_lines = min(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(lines.size(), max(free_height/line_spacing, 1U)); if(fit_height) *fit_height = line_height+(n_lines-1)*line_spacing;