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

item[R]

The wrapped item.

penalty[R]

The penalty for breaking at this point.

width[R]

The width assigned to this item.

Public Class Methods

new(penalty, width = 0, item: nil) click to toggle source

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

type() click to toggle source

Returns :penalty.

# File lib/hexapdf/layout/text_layouter.rb, line 171
def type
  :penalty
end