class HexaPDF::Layout::TextLayouter::Penalty
Used for layouting. Describes a penalty item, i.e. a point where a break is allowed.
If the penalty is greater than or equal to INFINITY
, a break is forbidden. If it is smaller than or equal to -INFINITY, a break is mandatory.
If a penalty contains an item and a break occurs at the penalty (taking the width of the penalty/item into account), then the penality item must be the last item of the line.
Constants
- INFINITY
All numbers greater than this one are deemed infinite.
- LINE_BREAK
The penalty value for a mandatory line break.
- PARAGRAPH_BREAK
The penalty value for a mandatory paragraph break.
- ProhibitedBreak
Singleton object describing a
Penalty
for a prohibited break.- Standard
Singleton object describing a standard
Penalty
, e.g. for hyphens.
Attributes
The wrapped item.
The penalty for breaking at this point.
The width assigned to this item.
Public Class Methods
Creates a new Penalty
with the given penality.
# File lib/hexapdf/layout/text_layouter.rb, line 164 def initialize(penalty, width = 0, item: nil) @penalty = penalty @width = width @item = item end
Public Instance Methods
Returns :penalty.
# File lib/hexapdf/layout/text_layouter.rb, line 171 def type :penalty end