diff options
author | Sebastian Geerken <devnull@localhost> | 2014-04-04 16:41:30 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-04-04 16:41:30 +0200 |
commit | 5a768078389e77dafcdb6ff566428996907a7c44 (patch) | |
tree | 6a7ea05210d713c166b78b6af9a39af025b166cf /dw/textblock_linebreaking.cc | |
parent | 109ab35947e641d28e47adf36a3275cf0d777e37 (diff) |
Fixed Textblock::balanceBreakPosAndHeight.
Diffstat (limited to 'dw/textblock_linebreaking.cc')
-rw-r--r-- | dw/textblock_linebreaking.cc | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 17ace7f2..d2a43d6a 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -872,9 +872,9 @@ void Textblock::balanceBreakPosAndHeight (int wordIndex, int firstIndex, // (As a side effect, this will lead to a larger break position, // and so place as much words as possible in the line.) - bool firstRun = true; + int runNo = 1; while (true) { - if (!(borderIsCalculated && firstRun)) { + if (!(borderIsCalculated && runNo == 1)) { // borderIsCalculated is, of course, only valid in the first run calcBorders (lastFloatPos, *height); *thereWillBeMoreSpace = regardBorder ? @@ -895,27 +895,36 @@ void Textblock::balanceBreakPosAndHeight (int wordIndex, int firstIndex, int newHeight = calcLinePartHeight (firstIndex, newBreakPos); DBG_OBJ_MSGF ("construct.word", 1, - "firstRun = %s, newBreakPos = %d, newHeight = %d " - "(height = %d)", - firstRun ? "true" : "false", newBreakPos, newHeight, - *height); - - if (!firstRun && newHeight >= *height) { - // - newHeight > height: do not proceed, discard new values, - // which are less desirable than the old ones (see above). - // - newHeight == height: convergence, stop here. New values - // can be discarded, since they are the same. - // (Since *some* value are needed, the results from the first - // run are never discarded.) - DBG_OBJ_MSG ("construct.word", 1, "discarding new values"); + "runNo = %d, newBreakPos = %d, newHeight = %d", + runNo, newBreakPos, newHeight); + if (runNo == 1) + DBG_OBJ_MSGF ("construct.word", 1, + "old: height = %d, breakPos undefined", *height); + else + DBG_OBJ_MSGF ("construct.word", 1, + "old: height = %d, breakPos = %d", *height, *breakPos); + + if (runNo != 1 /* Since *some* value are needed, the results + from the first run are never discarded. */ + && newHeight >= *height) { + if (newHeight == *height) { + // newHeight == height: convergence, stop here. The new break + // position is, nevertheless, adopted. + DBG_OBJ_MSG ("construct.word", 1, "stopping, adopting new values"); + *breakPos = newBreakPos; + } else + // newHeight > height: do not proceed, discard new values, + // which are less desirable than the old ones (see above). + DBG_OBJ_MSG ("construct.word", 1, + "stopping, discarding new values"); break; } else { - DBG_OBJ_MSG ("construct.word", 1, "adopting new values"); + DBG_OBJ_MSG ("construct.word", 1, "adopting new values, continuing"); *height = newHeight; *breakPos = newBreakPos; } - firstRun = false; + runNo++; } DBG_OBJ_MSG_END (); |