class HexaPDF:: Layout:: Line
Parent | Object |
---|
A Line
describes a line of text and can contain TextFragment
objects or InlineBox
objects.
The items of a line fragment are aligned along the x-axis which coincides with the text baseline. The vertical alignment is determined by the value of the valign method:
- :text_top
-
Align the top of the box with the top of the text of the
Line
. - :text_bottom
-
Align the bottom of the box with the bottom of the text of the
Line
. - :baseline
-
Align the bottom of the box with the baseline of the
Line
. - :top
-
Align the top of the box with the top of the
Line
. - :bottom
-
Align the bottom of the box with the bottom of the
Line
. - :text
-
This is a special alignment value for text fragment objects. The text fragment is aligned on the baseline and its minimum and maximum y-coordinates are used when calculating the line’s
text_y_min
andtext_y_max
.This value may be used by other objects if they should be handled similar to text fragments, e.g. graphical representation of characters (think: emoji fonts).
Item Requirements¶ ↑
Each item of a line fragment has to respond to the following methods:
x_min
-
The minimum x-coordinate of the item.
x_max
-
The maximum x-coordinate of the item.
width
-
The width of the item.
- valign
-
The vertical alignment of the item (see above).
- draw(canvas, x, y)
-
Should draw the item onto the canvas at the position (x, y).
If an item has a vertical alignment of :text, it additionally has to respond to the following methods:
Otherwise (i.e. a vertical alignment different from :text), the following method must be implemented:
height
-
The height of the item.
Attributes
The items: TextFragment
and InlineBox
objects
An optional horizontal offset that should be taken into account when positioning the line.
This offset always describes the offset from the left side (and not, for example, the offset from the right side of another line even if those two lines are actually on the same horizontal level).
An optional vertical offset that should be taken into account when positioning the line.
For the first line in a paragraph this describes the offset from the top of the box to the baseline of the line. For all other lines it describes the offset from the previous baseline to the baseline of this line.
Public Class Methods
Public Instance Methods
Adds the given item at the end of the item list.
If both the item and the last item in the item list are TextFragment
objects with the same attributes, they are combined.
Note: The cache is not cleared!
Clears all cached values.
This method needs to be called if the line’s items are changed!
Yields each item together with its horizontal offset from 0 and vertical offset from the baseline.
The height of the line fragment.
Specifies that this line should not be justified if line justification is used.
Returns true
if justification should be ignored for this line.
The maximum y-coordinate of any TextFragment
item of the line.
The minimum y-coordinate of any TextFragment
item of the line.
The width of the line fragment.
The maximum x-coordinate of the whole line.
The minimum x-coordinate of the whole line.
The maximum y-coordinate of any item of the line.
It is always greater than or equal to zero.
The minimum y-coordinate of any item of the line.
It is always lower than or equal to zero.