diff options
Diffstat (limited to 'dw')
-rw-r--r-- | dw/textblock.hh | 12 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 15 |
2 files changed, 17 insertions, 10 deletions
diff --git a/dw/textblock.hh b/dw/textblock.hh index 12950ec3..8482ac49 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -179,12 +179,14 @@ private: INF_VALUE = 0, /* simple values */ INF_LARGE, /* large values, like QUITE_LOOSE */ INF_NOT_STRETCHABLE, /* reserved for NOT_STRECTHABLE */ + INF_TOO_TIGHT, /* used for lines, which are too tight */ INF_PENALTIES, /* used for penalties */ - INF_TOO_TIGHT, /* used for lines, which are too tight; - that this is the last value means - that lines, which are too tight, are - regarded as the worst case */ - INF_MAX = INF_TOO_TIGHT + INF_MAX = INF_PENALTIES + + // That INF_PENALTIES is the last value means that an + // infinite penalty (breaking is prohibited) makes a break + // not possible at all, so that pre-formatted text + // etc. works. }; int badnessValue (int infLevel); diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 1a0d72f9..52f1f4e0 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -529,13 +529,18 @@ void Textblock::wordWrap (int wordIndex, bool wrapAll) if (wrapAll && searchUntil == words->size () - 1) { // Since no break and no space is added, the last word - // will have a penalty of inf. Actually, it should be -inf, - // since it is the last word. However, since more words may - // follow, the penalty is not changesd, but here, the search - // is corrected (maybe only temporary). + // will have a penalty of inf. Actually, it should be + // less, since it is the last word. However, since more + // words may follow, the penalty is not changesd, but + // here, the search is corrected (maybe only + // temporary). + + // (Notice that it was once (temporally) set to -inf, + // not 0, but this will make e.g. test/table-1.html not + // work.) Word *lastWord = words->getRef (searchUntil); BadnessAndPenalty correctedBap = lastWord->badnessAndPenalty; - correctedBap.setPenaltyForceBreak (); + correctedBap.setPenalty (0); if (correctedBap.compareTo (&words->getRef(breakPos)->badnessAndPenalty) <= 0) { breakPos = searchUntil; |