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:
Align the top of the box with the top of the text of the
Align the bottom of the box with the bottom of the text of the
Align the bottom of the box with the baseline of the
Align the top of the box with the top of the
Align the bottom of the box with the bottom of the
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
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).
Each item of a line fragment has to respond to the following methods:
The minimum x-coordinate of the item.
The maximum x-coordinate of the item.
The width of the item.
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:
The height of the item.
An optional horizontal offset that should be taken into account when positioning the line.
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.
true if justification should be ignored for this 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.