From 6cf170c2c9aa8323a83bd897e13d43849a93fbf8 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Sun, 30 Jan 2022 14:31:11 +0000 Subject: [PATCH] Text boxes: Return full word even if it doesn't fit in the column width It does mean that the text now can be outside the text box, but this is better than an infinite loop. Fixes https://gitlab.com/kicad/code/kicad/-/issues/10668 --- common/font/font.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/common/font/font.cpp b/common/font/font.cpp index e3b6922169..325e539dbe 100644 --- a/common/font/font.cpp +++ b/common/font/font.cpp @@ -454,17 +454,24 @@ void FONT::LinebreakText( wxString& aText, int aColumnWidth, const VECTOR2I& aSi aText += " "; lineWidth += spaceWidth; } - - aText += words[jj].first; - lineWidth += words[jj].second; - - jj++; } - else + else if( lineWidth > 0 ) { aText += '\n'; lineWidth = 0; + continue; + } + else + { + // TODO: Would we want to further split the words into characters when it doesn't fit + // in the column width? For now just return the full word even if it doesn't fit + // to avoid an infinite loop. } + + aText += words[jj].first; + lineWidth += words[jj].second; + + jj++; } } }