diff options
author | sgeerken <devnull@localhost> | 2012-08-31 19:31:14 +0200 |
---|---|---|
committer | sgeerken <devnull@localhost> | 2012-08-31 19:31:14 +0200 |
commit | 539890c5ff0d38eca56e74b7460ed7de5d15e4b0 (patch) | |
tree | 39c224dc00990ebb3bd324766c9d0eeab5973cd4 /dw/textblock_linebreaking.cc | |
parent | 57f608a4e4e379524d496be2826d9a6bd6729e26 (diff) |
Cleaned up calculation of extremes (still a bit to do).
Diffstat (limited to 'dw/textblock_linebreaking.cc')
-rw-r--r-- | dw/textblock_linebreaking.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index cd00e392..05a9e8eb 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -333,8 +333,8 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord, lineWidth += (word->effSpace - word->origSpace); } - if (lines->size () == 1) { + // first line line->top = 0; // TODO What to do with this one: lastLine->maxLineWidth = line1OffsetEff; @@ -382,14 +382,35 @@ Textblock::Line *Textblock::addLine (int firstWord, int lastWord, void Textblock::accumulateWordExtremees (int firstWord, int lastWord, int *maxOfMinWidth, int *sumOfMaxWidth) { + int parMin = 0; *maxOfMinWidth = *sumOfMaxWidth = 0; for (int i = firstWord; i <= lastWord; i++) { Word *word = words->getRef (i); + bool atLastWord = i == lastWord; + core::Extremes extremes; getWordExtremes (word, &extremes); - *maxOfMinWidth = misc::min (*maxOfMinWidth, extremes.minWidth); + // Minimum: between two *possible* breaks (or at the end). + // TODO This is redundant to getExtremesImpl(). + if (word->badnessAndPenalty.lineCanBeBroken () || atLastWord) { + parMin += extremes.minWidth + word->hyphenWidth; + *maxOfMinWidth = misc::max (*maxOfMinWidth, parMin); + parMin = 0; + } else + // Shrinkability could be considered, but really does not play a + // role. + parMin += extremes.minWidth + word->origSpace; + + //printf ("[%p] after word: ", this); + //printWord (word); + //printf ("\n"); + + //printf ("[%p] (%d / %d) => parMin = %d, maxOfMinWidth = %d\n", + // this, extremes.minWidth, extremes.maxWidth, parMin, + // *maxOfMinWidth); + *sumOfMaxWidth += (extremes.maxWidth + word->origSpace); // Regarding the sum: if this is the end of the paragraph, it // does not matter, since word->space is 0 in this case. |