Dillo v3.1.1-119-g140d9ebd
|
Public Member Functions | |
void | calcBadness (int totalWidth, int idealWidth, int totalStretchability, int totalShrinkability) |
void | setPenalty (int penalty) |
void | setPenalties (int penalty1, int penalty2) |
Sets the penalty, multiplied by 100. | |
int | getPenalty (int i) |
bool | lineLoose () |
bool | lineTight () |
bool | lineTooTight () |
bool | lineMustBeBroken (int penaltyIndex) |
bool | lineCanBeBroken (int penaltyIndex) |
int | compareTo (int penaltyIndex, BadnessAndPenalty *other) |
void | intoStringBuffer (lout::misc::StringBuffer *sb) |
Private Types | |
enum | { NOT_STRETCHABLE , QUITE_LOOSE , BADNESS_VALUE , TOO_TIGHT } |
enum | { INF_VALUE = 0 , INF_LARGE , INF_NOT_STRETCHABLE , INF_TOO_TIGHT , INF_PENALTIES , INF_MAX = INF_PENALTIES } |
Private Member Functions | |
void | setSinglePenalty (int index, int penalty) |
int | badnessValue (int infLevel) |
int | penaltyValue (int index, int infLevel) |
Private Attributes | |
enum dw::Textblock::BadnessAndPenalty:: { ... } | badnessState |
int | ratio |
int | badness |
int | penalty [2] |
Definition at line 222 of file textblock.hh.
|
private |
Enumerator | |
---|---|
NOT_STRETCHABLE | |
QUITE_LOOSE | |
BADNESS_VALUE | |
TOO_TIGHT |
Definition at line 225 of file textblock.hh.
|
private |
Enumerator | |
---|---|
INF_VALUE | |
INF_LARGE | |
INF_NOT_STRETCHABLE | |
INF_TOO_TIGHT | |
INF_PENALTIES | |
INF_MAX |
Definition at line 246 of file textblock.hh.
|
private |
Definition at line 37 of file textblock_linebreaking.cc.
References lout::misc::assertNotReached(), badness, BADNESS_VALUE, badnessState, INF_LARGE, INF_NOT_STRETCHABLE, INF_TOO_TIGHT, INF_VALUE, NOT_STRETCHABLE, QUITE_LOOSE, and TOO_TIGHT.
Referenced by compareTo().
void dw::Textblock::BadnessAndPenalty::calcBadness | ( | int | totalWidth, |
int | idealWidth, | ||
int | totalStretchability, | ||
int | totalShrinkability | ||
) |
Definition at line 68 of file textblock_linebreaking.cc.
References dw::core::Widget::ratio.
Referenced by dw::Textblock::accumulateWordData().
int dw::Textblock::BadnessAndPenalty::compareTo | ( | int | penaltyIndex, |
BadnessAndPenalty * | other | ||
) |
Definition at line 180 of file textblock_linebreaking.cc.
References badnessValue(), and penaltyValue().
Referenced by dw::Textblock::searchMinBap().
|
inline |
Definition at line 271 of file textblock.hh.
References penalty.
void dw::Textblock::BadnessAndPenalty::intoStringBuffer | ( | lout::misc::StringBuffer * | sb | ) |
Definition at line 195 of file textblock_linebreaking.cc.
References lout::misc::StringBuffer::append(), lout::misc::StringBuffer::appendInt(), and dw::core::Widget::ratio.
Referenced by dw::Textblock::accumulateWordData(), and dw::Textblock::searchMinBap().
bool dw::Textblock::BadnessAndPenalty::lineCanBeBroken | ( | int | penaltyIndex | ) |
Definition at line 175 of file textblock_linebreaking.cc.
References dw::Textblock::PENALTY_PROHIBIT_BREAK.
Referenced by dw::Textblock::correctLastWordExtremes(), and dw::Textblock::handleWordExtremes().
bool dw::Textblock::BadnessAndPenalty::lineLoose | ( | ) |
Definition at line 151 of file textblock_linebreaking.cc.
References dw::core::Widget::ratio.
Referenced by dw::Textblock::considerHyphenation().
bool dw::Textblock::BadnessAndPenalty::lineMustBeBroken | ( | int | penaltyIndex | ) |
Definition at line 170 of file textblock_linebreaking.cc.
References dw::Textblock::PENALTY_FORCE_BREAK.
Referenced by dw::Textblock::setBreakOption().
bool dw::Textblock::BadnessAndPenalty::lineTight | ( | ) |
Definition at line 158 of file textblock_linebreaking.cc.
References dw::core::Widget::ratio.
Referenced by dw::Textblock::considerHyphenation().
bool dw::Textblock::BadnessAndPenalty::lineTooTight | ( | ) |
Definition at line 164 of file textblock_linebreaking.cc.
|
private |
Definition at line 58 of file textblock_linebreaking.cc.
References dw::Textblock::index.
Referenced by compareTo().
void dw::Textblock::BadnessAndPenalty::setPenalties | ( | int | penalty1, |
int | penalty2 | ||
) |
Sets the penalty, multiplied by 100.
Multiplication is necessary to deal with fractional numbers, without having to use floating point numbers. So, to set a penalty to 0.5, pass 50.
INT_MAX and INT_MIN (representing inf and -inf, respectively) are also allowed.
The definition of penalties depends on the definition of badness, which adheres to the description in Changes in Line-Breaking and Hyphenation, section "Criteria for Line-Breaking". The exact calculation may vary, but this definition of should be rather stable: (i) A perfectly fitting line has a badness of 0. (ii) A line, where all spaces are extended by exactly the stretchability, as well as a line, where all spaces are reduced by the shrinkability, have a badness of 1.
(TODO plural: penalties, not penalty. Correct above comment)
Definition at line 130 of file textblock_linebreaking.cc.
Referenced by dw::Textblock::hyphenateWord(), dw::Textblock::setBreakOption(), and setPenalty().
|
inline |
Definition at line 267 of file textblock.hh.
References penalty, and setPenalties().
Referenced by dw::Textblock::addLinebreak(), dw::Textblock::addParbreak(), dw::Textblock::fillWord(), dw::Textblock::searchMinBap(), and dw::Textblock::setBreakOption().
|
private |
Definition at line 137 of file textblock_linebreaking.cc.
References dw::Textblock::index.
|
private |
Definition at line 228 of file textblock.hh.
Referenced by badnessValue().
enum { ... } dw::Textblock::BadnessAndPenalty::badnessState |
Referenced by badnessValue().
|
private |
Definition at line 228 of file textblock.hh.
Referenced by getPenalty(), and setPenalty().
|
private |
Definition at line 227 of file textblock.hh.