From 8a911be6fd3c2840befcef44ac7b24969563d34e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 12 Sep 2019 12:11:39 +0300 Subject: [PATCH] Improve vertical positioning of text Applying alignment to only the number of lines that fit in the widget results in a more consistent position. --- source/text.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/text.cpp b/source/text.cpp index 1d7a793..cdaae85 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -227,12 +227,12 @@ void Text::process_lines(const Part &part, const Geometry &parent, unsigned firs float font_size = style->get_font_size(); unsigned line_height = static_cast((font.get_ascent()-font.get_descent())*font_size); unsigned line_spacing = static_cast(font_size*6/5); - unsigned height = line_height+(lines.size()-1)*line_spacing; int y_offset = static_cast(-font.get_descent()*font_size); const Sides &margin = part.get_margin(); unsigned fit_height = parent.h-margin.top-margin.bottom+line_spacing-line_height; unsigned n_lines = min(lines.size(), max(fit_height/line_spacing, 1U)); + fit_height = line_height+(n_lines-1)*line_spacing; first_row = min(first_row, lines.size()-n_lines); for(unsigned i=0; i