From 57625a1ea9463c5ef4d175d4c5f06ba665ce10f9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 22 May 2020 20:51:53 +0100 Subject: [PATCH] WordWrapper: preserve word order --- src/main/java/net/kemitix/text/fit/TextLineWrapImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/kemitix/text/fit/TextLineWrapImpl.java b/src/main/java/net/kemitix/text/fit/TextLineWrapImpl.java index 7ad68c2..e5849ac 100644 --- a/src/main/java/net/kemitix/text/fit/TextLineWrapImpl.java +++ b/src/main/java/net/kemitix/text/fit/TextLineWrapImpl.java @@ -52,7 +52,7 @@ class TextLineWrapImpl implements WordWrapper { while (!wordQ.isEmpty()) { Word word = wordQ.pop(); if ((bottom + word.height) > height) { - wordQ.push(word); + wordQ.add(word); lineQ.forEach(wordQ::push); return removeBlankLines(lines); } @@ -65,7 +65,7 @@ class TextLineWrapImpl implements WordWrapper { end = 0; bottom += word.height; } - lineQ.push(word); + lineQ.add(word); end += word.width; } lines.add(wordsAsString(lineQ));