Package playn.core
Class TextLayout
java.lang.Object
playn.core.TextLayout
Contains metrics and metadata for a laid out body of text. The text may subsequently be rendered
to a canvas.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal IRectangleReturns the precise bounds of the text rendered by this layout.final TextFormatTheTextFormatused to lay out this text.final IDimensionThe size of the bounding box that contains all of the rendered text.final StringThe text that was laid out. -
Method Summary
Modifier and TypeMethodDescriptionabstract floatascent()The number of pixels from the top of a line of text to the baseline.abstract floatdescent()The number of pixels from the baseline to the bottom of a line of text.abstract floatleading()The number of pixels between the bottom of one line of text and the top of the next.static StringnormalizeEOL(String text) A helper function for normalizing EOL prior to processing.
-
Field Details
-
text
The text that was laid out. -
format
TheTextFormatused to lay out this text. -
bounds
Returns the precise bounds of the text rendered by this layout. The x and y position may be non-zero if the text is rendered somewhat offset from the "natural" origin of the text line. Unfortunately x may even be negative in some cases which makes rendering the text into a bespoke image troublesome.TextBlockprovides methods to help with this. -
size
The size of the bounding box that contains all of the rendered text. Note: the height is the height of a line of text. It is not a tight bounding box, but rather the ascent plus the descent and is thus consistent regardless of what text is rendered. Useboundsif you want the precise height of just the rendered text.
-
-
Method Details
-
ascent
public abstract float ascent()The number of pixels from the top of a line of text to the baseline. -
descent
public abstract float descent()The number of pixels from the baseline to the bottom of a line of text. -
leading
public abstract float leading()The number of pixels between the bottom of one line of text and the top of the next. -
normalizeEOL
A helper function for normalizing EOL prior to processing.
-