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
Modifier and TypeFieldDescriptionfinal IRectangle
Returns the precise bounds of the text rendered by this layout.final TextFormat
TheTextFormat
used to lay out this text.final IDimension
The size of the bounding box that contains all of the rendered text.final String
The text that was laid out. -
Method Summary
Modifier and TypeMethodDescriptionabstract float
ascent()
The number of pixels from the top of a line of text to the baseline.abstract float
descent()
The number of pixels from the baseline to the bottom of a line of text.abstract float
leading()
The number of pixels between the bottom of one line of text and the top of the next.static String
normalizeEOL
(String text) A helper function for normalizing EOL prior to processing.
-
Field Details
-
text
The text that was laid out. -
format
TheTextFormat
used 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.TextBlock
provides 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. Usebounds
if 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.
-