Dillo v3.1.1-111-gd4f56d0d
Loading...
Searching...
No Matches
dw::Textblock::BadnessAndPenalty Class Reference

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]
 

Detailed Description

Definition at line 222 of file textblock.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
NOT_STRETCHABLE 
QUITE_LOOSE 
BADNESS_VALUE 
TOO_TIGHT 

Definition at line 225 of file textblock.hh.

◆ anonymous enum

anonymous enum
private
Enumerator
INF_VALUE 
INF_LARGE 
INF_NOT_STRETCHABLE 
INF_TOO_TIGHT 
INF_PENALTIES 
INF_MAX 

Definition at line 246 of file textblock.hh.

Member Function Documentation

◆ badnessValue()

int dw::Textblock::BadnessAndPenalty::badnessValue ( int  infLevel)
private

◆ calcBadness()

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().

◆ compareTo()

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().

◆ getPenalty()

int dw::Textblock::BadnessAndPenalty::getPenalty ( int  i)
inline

Definition at line 271 of file textblock.hh.

References penalty.

◆ intoStringBuffer()

void dw::Textblock::BadnessAndPenalty::intoStringBuffer ( lout::misc::StringBuffer sb)

◆ lineCanBeBroken()

bool dw::Textblock::BadnessAndPenalty::lineCanBeBroken ( int  penaltyIndex)

◆ lineLoose()

bool dw::Textblock::BadnessAndPenalty::lineLoose ( )

Definition at line 151 of file textblock_linebreaking.cc.

References dw::core::Widget::ratio.

Referenced by dw::Textblock::considerHyphenation().

◆ lineMustBeBroken()

bool dw::Textblock::BadnessAndPenalty::lineMustBeBroken ( int  penaltyIndex)

◆ lineTight()

bool dw::Textblock::BadnessAndPenalty::lineTight ( )

Definition at line 158 of file textblock_linebreaking.cc.

References dw::core::Widget::ratio.

Referenced by dw::Textblock::considerHyphenation().

◆ lineTooTight()

bool dw::Textblock::BadnessAndPenalty::lineTooTight ( )

Definition at line 164 of file textblock_linebreaking.cc.

◆ penaltyValue()

int dw::Textblock::BadnessAndPenalty::penaltyValue ( int  index,
int  infLevel 
)
private

Definition at line 58 of file textblock_linebreaking.cc.

References dw::Textblock::index.

Referenced by compareTo().

◆ setPenalties()

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().

◆ setPenalty()

void dw::Textblock::BadnessAndPenalty::setPenalty ( int  penalty)
inline

◆ setSinglePenalty()

void dw::Textblock::BadnessAndPenalty::setSinglePenalty ( int  index,
int  penalty 
)
private

Definition at line 137 of file textblock_linebreaking.cc.

References dw::Textblock::index.

Member Data Documentation

◆ badness

int dw::Textblock::BadnessAndPenalty::badness
private

Definition at line 228 of file textblock.hh.

Referenced by badnessValue().

◆ []

enum { ... } dw::Textblock::BadnessAndPenalty::badnessState

Referenced by badnessValue().

◆ penalty

int dw::Textblock::BadnessAndPenalty::penalty[2]
private

Definition at line 228 of file textblock.hh.

Referenced by getPenalty(), and setPenalty().

◆ ratio

int dw::Textblock::BadnessAndPenalty::ratio
private

Definition at line 227 of file textblock.hh.


The documentation for this class was generated from the following files: