class HexaPDF::Layout::TextBox

Parent

A TextBox is used for drawing text, either inside a rectangular box or by flowing it around objects of a Frame.

This class uses TextLayouter behind the scenes to do the hard work.

Public Class Methods

new(items:, **kwargs)

Creates a new TextBox object with the given inline items (e.g. TextFragment and InlineBox objects).

Calls superclass method HexaPDF::Layout::Box::new

Public Instance Methods

fit(available_width, available_height, frame)

Fits the text box into the Frame.

Depending on the ‘position’ style property, the text is either fit into the current region of the frame using available_width and available_height, or fit to the shape of the frame starting from the top (when ‘position’ is set to :flow).

The spacing after the last line can be controlled via the style property last_line_gap.

Also see TextLayouter#style for other style properties taken into account.

split(available_width, available_height, frame)

Splits the text box into two boxes if necessary and possible.

supports_position_flow?()

Returns true as the ‘position’ style property value :flow is supported.

text()

Returns the text that will be drawn.

This will ignore any inline boxes or kerning values.