]> git.tdb.fi Git - libs/gltk.git/commitdiff
Fix line processing in Text to match autosizing
authorMikko Rasa <tdb@tdb.fi>
Wed, 22 Jan 2014 19:51:14 +0000 (21:51 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 22 Jan 2014 19:51:14 +0000 (21:51 +0200)
source/text.cpp

index aa5ad8030efe6be34a08218932e4c0d284d2a98f..8ef17392f353259c0fa83ec95b1f5b4e6a08a41c 100644 (file)
@@ -231,7 +231,8 @@ void Text::process_lines(const Part &part, const Geometry &parent, unsigned firs
        int y_offset = static_cast<int>(-font.get_descent()*font_size);
 
        const Sides &margin = part.get_margin();
-       unsigned n_lines = min<unsigned>(lines.size(), max((parent.h-margin.top-margin.bottom)/line_spacing, 1U));
+       unsigned fit_height = parent.h-margin.top-margin.bottom+line_spacing-line_height;
+       unsigned n_lines = min<unsigned>(lines.size(), max(fit_height/line_spacing, 1U));
        first_row = min<unsigned>(first_row, lines.size()-n_lines);
 
        for(unsigned i=0; i<n_lines; ++i)