diff options
author | sgeerken <devnull@localhost> | 2012-09-05 15:02:03 +0200 |
---|---|---|
committer | sgeerken <devnull@localhost> | 2012-09-05 15:02:03 +0200 |
commit | 60e562a0bb7329c6f6e9d66faad567cf660b01a4 (patch) | |
tree | 798c2599843451a2d6f51805b8d2b071ac63e1e5 /dw/textblock_linebreaking.cc | |
parent | df78d47c4845622e76fd719d15a0e060d999d318 (diff) |
Corrected comparison between too loose and too tight lines.
Diffstat (limited to 'dw/textblock_linebreaking.cc')
-rw-r--r-- | dw/textblock_linebreaking.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index 7559f38e..f2175803 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -154,6 +154,19 @@ bool Textblock::BadnessAndPenalty::lineCanBeBroken () int Textblock::BadnessAndPenalty::compareTo (BadnessAndPenalty *other) { + // First, a special condition: if a line is too tight, it will + // always be regarded as worse than a line, which is not too + // tight. Especially, lines too tight are worse than lines too + // loose. See test/table-1.html as a text case: the first line, + // which contains only the word "Short,", is too loose, but not + // breaking here would make the line too tight, making the text + // overwrap the available space. + + if (lineTooTight() && !other->lineTooTight()) + return 1; + if (!lineTooTight() && other->lineTooTight()) + return -1; + int thisNumInffinities = badnessInffinities () + penaltyInffinities (); int otherNumInffinities = other->badnessInffinities () + other->penaltyInffinities (); |