aboutsummaryrefslogtreecommitdiff
path: root/dw/textblock_linebreaking.cc
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-03-20 14:01:19 +0100
committerSebastian Geerken <devnull@localhost>2014-03-20 14:01:19 +0100
commit9679bf0b486abadd16f25e0d212c7732f0dad9d5 (patch)
tree36e768710fe7154a996913930dbaa5b1046df4b0 /dw/textblock_linebreaking.cc
parent443596beeec3243fdc69f53b1ca57d2810a5f0af (diff)
Fixed a bug related to line breaking. (Originally applied to floats repo.)
Diffstat (limited to 'dw/textblock_linebreaking.cc')
-rw-r--r--dw/textblock_linebreaking.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc
index c07dc602..32e400fa 100644
--- a/dw/textblock_linebreaking.cc
+++ b/dw/textblock_linebreaking.cc
@@ -1148,12 +1148,16 @@ void Textblock::alignLine (int lineIndex)
break;
case core::style::TEXT_ALIGN_JUSTIFY: /* see some lines above */
line->leftOffset = 0;
- if(lastWord->content.type != core::Content::BREAK &&
- line->lastWord != words->size () - 1) {
- PRINTF (" justifyLine => %d vs. %d\n",
- lastWord->totalWidth, availWidth);
+ // Do not justify the last line of a paragraph (which ends on a
+ // BREAK or with the last word of the page).
+ if(!(lastWord->content.type == core::Content::BREAK ||
+ line->lastWord == words->size () - 1) ||
+ // In some cases, however, an unjustified line would be too wide:
+ // when the line would be shrunken otherwise. (This solution is
+ // far from perfect, but a better solution would make changes in
+ // the line breaking algorithm necessary.)
+ availWidth < lastWord->totalWidth)
justifyLine (line, availWidth - lastWord->totalWidth);
- }
break;
case core::style::TEXT_ALIGN_RIGHT:
line->leftOffset = availWidth - lastWord->totalWidth;