Dillo
|
Public Member Functions | |
void | calcBadness (int totalWidth, int idealWidth, int totalStretchability, int totalShrinkability) |
void | setPenalty (int penalty) |
void | setPenalties (int penalty1, int penalty2) |
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] |
|
private |
|
private |
References lout::misc::assertNotReached().
Referenced by compareTo().
void dw::Textblock::BadnessAndPenalty::calcBadness | ( | int | totalWidth, |
int | idealWidth, | ||
int | totalStretchability, | ||
int | totalShrinkability | ||
) |
Referenced by dw::Textblock::accumulateWordData().
int dw::Textblock::BadnessAndPenalty::compareTo | ( | int | penaltyIndex, |
BadnessAndPenalty * | other | ||
) |
References badnessValue(), and penaltyValue().
Referenced by dw::Textblock::searchMinBap().
|
inline |
void dw::Textblock::BadnessAndPenalty::intoStringBuffer | ( | lout::misc::StringBuffer * | sb | ) |
References lout::misc::StringBuffer::append(), and lout::misc::StringBuffer::appendInt().
Referenced by dw::Textblock::accumulateWordData(), and dw::Textblock::searchMinBap().
bool dw::Textblock::BadnessAndPenalty::lineCanBeBroken | ( | int | penaltyIndex | ) |
Referenced by dw::Textblock::correctLastWordExtremes(), and dw::Textblock::handleWordExtremes().
bool dw::Textblock::BadnessAndPenalty::lineLoose | ( | ) |
Referenced by dw::Textblock::considerHyphenation().
bool dw::Textblock::BadnessAndPenalty::lineMustBeBroken | ( | int | penaltyIndex | ) |
Referenced by dw::Textblock::setBreakOption(), and dw::Textblock::wrapWordInFlow().
bool dw::Textblock::BadnessAndPenalty::lineTight | ( | ) |
Referenced by dw::Textblock::considerHyphenation().
bool dw::Textblock::BadnessAndPenalty::lineTooTight | ( | ) |
Referenced by dw::Textblock::wrapWordInFlow().
|
private |
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)
Referenced by dw::Textblock::hyphenateWord(), dw::Textblock::setBreakOption(), and setPenalty().
|
inline |
References setPenalties().
Referenced by dw::Textblock::addLinebreak(), dw::Textblock::addParbreak(), dw::Textblock::fillWord(), dw::Textblock::searchMinBap(), and dw::Textblock::setBreakOption().
|
private |
|
private |
enum { ... } dw::Textblock::BadnessAndPenalty::badnessState |
|
private |
|
private |