From 418a05d6368d23fc6ccb90c024b37e6e0c134d18 Mon Sep 17 00:00:00 2001 From: twanvl Date: Sat, 16 Oct 2010 19:29:57 +0000 Subject: [PATCH] Fix error introduced in r1465: in single line text box, no lines were generated (which led to a crash), or text was scaled down when this was not intended. git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1524 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/render/text/viewer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/render/text/viewer.cpp b/src/render/text/viewer.cpp index bf69e958..c8e26357 100644 --- a/src/render/text/viewer.cpp +++ b/src/render/text/viewer.cpp @@ -350,6 +350,7 @@ void TextViewer::prepareElements(const String& text, const TextStyle& style, Con void TextViewer::prepareLines(RotatedDC& dc, const String& text, TextStyle& style, Context& ctx) { vector chars; prepareLinesTryScales(dc, text, style, chars); + assert(!lines.empty()); // store information about the content/layout, allow this to change alignment style.content_width = 0; @@ -559,7 +560,7 @@ bool TextViewer::prepareLinesScale(RotatedDC& dc, const vector& chars, if (line_size.width + word_size.width > max_width) { if (!style.field().multi_line) { // single line word does not fit - return false; + if (stop_if_too_long) return false; } else if (word_start == line.start) { // single word on this line; the word is too long if (stop_if_too_long) { @@ -683,6 +684,7 @@ void TextViewer::alignLines(RotatedDC& dc, const vector& chars, const -RealSize(style.padding_left+style.padding_right, style.padding_top + style.padding_bottom)); if (style.paragraph_height <= 0) { // whole text box alignment + assert(!lines.empty()); double top = lines[0].top; alignParagraph(0, lines.size(), chars, style, RealRect(RealPoint(0,top),s)); } else {