runs of glyphs for a piece of text. The text may contain newlines and color markup tags.
Where wrapping occurs is determined by BitmapFontData#getWrapIndex(Array, int). Additionally, when
BitmapFontData#markupEnabled is true wrapping can occur at color start or end tags.
When wrapping occurs, whitespace is removed before and after the wrap position. Whitespace is determined by
BitmapFontData#isWhitespace(char).
Glyphs positions are determined by BitmapFontData#getGlyphs(GlyphRun, CharSequence, int, int, Glyph).
This class is not thread safe, even if synchronized externally, and must only be used from the game thread.
| Modifier and Type | Class and Description |
|---|---|
| public static class | GlyphLayout.
Stores glyphs and positions for a line of text. |
| public static enum |
| Modifier and Type | Field and Description |
|---|---|
| public final IntArray | |
| private static final IntArray | |
| private static final float | |
| public int | glyphCount
Number of glyphs across all |
| private static final Pool | |
| public float | |
| public final Array | runs
Each run has the glyphs for a line of text. |
| public float |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | GlyphLayout(BitmapFont font, CharSequence str, Color color, float targetWidth, int halign, boolean wrap)
|
| public | GlyphLayout(BitmapFont font, CharSequence str, int start, int end, Color color, float targetWidth, int halign, boolean wrap, String truncate)
|
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | calculateWidthsAndJustify(BitmapFont.
Calculate run widths and the entire layout width. |
| private float | getGlyphWidth(BitmapFont.
Returns the distance from the glyph's drawing position to the right edge of the glyph. |
| private float | getLineOffset(Array<BitmapFont.
Returns an X offset for the first glyph so when drawn, none of it is left of the line's drawing position. |
| private void | |
| private int | |
| public void | |
| private void | setLastGlyphXAdvance(BitmapFont.
Sets the xadvance of the last glyph to use its width instead of xadvance. |
| public void | setText(BitmapFont font, CharSequence str)
Calls |
| public void | setText(BitmapFont font, CharSequence str, Color color, float targetWidth, int halign, boolean wrap)
Calls |
| public void | setText(BitmapFont font, CharSequence str, int start, int end, Color
The default color to use for the text (the BitmapFont color, float color is not used). If
BitmapFontData#markupEnabled is true, color markup tags in the specified string may change the color for
portions of the text.The width used for alignment, line wrapping, and truncation. May be zero if those features are not used. targetWidth, int Horizontal alignment of the text, see halign, boolean wrap, String Align.If not null and the width of the glyphs exceed targetWidth, the glyphs are truncated and the glyphs for the
specified truncate string are placed at the end. Empty string can be used to truncate without adding glyphs.
Truncate should not be used with text that contains multiple lines. Wrap is ignored if truncate is not null. truncate)
|
| public void | setText(BitmapFont font, CharSequence str, int start, int end, Color
The default color to use for the text (the BitmapFont color, float color is not used). If
BitmapFontData#markupEnabled is true, color markup tags in the specified string may change the color for
portions of the text.The width used for alignment, line wrapping, and truncation. May be zero if those features are not used. targetWidth, int Horizontal alignment of the text, see halign, boolean wrap, Justify Align.Justification of the text, see justify, String Justify.If not null and the width of the glyphs exceed targetWidth, the glyphs are truncated and the glyphs for the
specified truncate string are placed at the end. Empty string can be used to truncate without adding glyphs.
Truncate should not be used with text that contains multiple lines. Wrap is ignored if truncate is not null. truncate)
|
| private static boolean | |
| public String | |
| private void | truncate(BitmapFont.
May be empty string. truncate)
|
| private GlyphLayout. | Returns: May be null if second run is all whitespace.Breaks a run into two runs at the specified wrapIndex. |
| colors | back to summary |
|---|---|
| public final IntArray colors Determines the colors of the glpyhs in the
For example:
The array is empty if there are no runs, otherwise it has at least two entries: | |
| colorStack | back to summary |
|---|---|
| private static final IntArray colorStack | |
| epsilon | back to summary |
|---|---|
| private static final float epsilon | |
| glyphCount | back to summary |
|---|---|
| public int glyphCount Number of glyphs across all | |
| glyphRunPool | back to summary |
|---|---|
| private static final Pool<GlyphLayout. | |
| height | back to summary |
|---|---|
| public float height | |
| runs | back to summary |
|---|---|
| public final Array<GlyphLayout. Each run has the glyphs for a line of text.
Runs are pooled, so references should not be kept past the next call to
| |
| width | back to summary |
|---|---|
| public float width | |
| GlyphLayout | back to summary |
|---|---|
| public GlyphLayout() Creates an empty GlyphLayout. | |
| GlyphLayout | back to summary |
|---|---|
public GlyphLayout(BitmapFont font, CharSequence str)
| |
| GlyphLayout | back to summary |
|---|---|
public GlyphLayout(BitmapFont font, CharSequence str, Color color, float targetWidth, int halign, boolean wrap)
| |
| GlyphLayout | back to summary |
|---|---|
public GlyphLayout(BitmapFont font, CharSequence str, int start, int end, Color color, float targetWidth, int halign, boolean wrap, String truncate)
| |
| alignRuns | back to summary |
|---|---|
| private void alignRuns(float targetWidth, int halign) Align runs to center or right of targetWidth. Requires run.width of runs to be already set | |
| calculateWidthsAndJustify | back to summary |
|---|---|
| private void calculateWidthsAndJustify(BitmapFont. Calculate run widths and the entire layout width. | |
| getGlyphWidth | back to summary |
|---|---|
| private float getGlyphWidth(BitmapFont. Returns the distance from the glyph's drawing position to the right edge of the glyph. | |
| getLineOffset | back to summary |
|---|---|
| private float getLineOffset(Array<BitmapFont. Returns an X offset for the first glyph so when drawn, none of it is left of the line's drawing position. | |
| justifyRun | back to summary |
|---|---|
| private void justifyRun(GlyphLayout. | |
| parseColorMarkup | back to summary |
|---|---|
| private int parseColorMarkup(CharSequence str, int start, int end) | |
| reset | back to summary |
|---|---|
| public void reset() Implements com. Doc from com. Resets the object for reuse. Object references should be nulled and fields may be set to default values. | |
| setLastGlyphXAdvance | back to summary |
|---|---|
| private void setLastGlyphXAdvance(BitmapFont. Sets the xadvance of the last glyph to use its width instead of xadvance. | |
| setText | back to summary |
|---|---|
| public void setText(BitmapFont font, CharSequence str) Calls | |
| setText | back to summary |
|---|---|
| public void setText(BitmapFont font, CharSequence str, Color color, float targetWidth, int halign, boolean wrap) Calls | |
| setText | back to summary |
|---|---|
public void setText(BitmapFont font, CharSequence str, int start, int end, Color color, float targetWidth, int halign, boolean wrap, String truncate)
| |
| setText | back to summary |
|---|---|
public void setText(BitmapFont font, CharSequence str, int start, int end, Color color, float targetWidth, int halign, boolean wrap, Justify justify, String truncate)
| |
| shouldJustify | back to summary |
|---|---|
| private static boolean shouldJustify(Justify justify, GlyphLayout. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| truncate | back to summary |
|---|---|
private void truncate(BitmapFont.
| |
| wrap | back to summary |
|---|---|
| private GlyphLayout. Breaks a run into two runs at the specified wrapIndex.
| |
| Modifier and Type | Field and Description |
|---|---|
| public Array | |
| public float | |
| public GlyphLayout. | |
| public float | |
| public FloatArray | xAdvances
Contains glyphs.size+1 entries: The first entry is the X offset relative to the drawing position. |
| public float |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public void | |
| public String |
| glyphs | back to summary |
|---|---|
| public Array<BitmapFont. | |
| width | back to summary |
|---|---|
| public float width | |
| wrapState | back to summary |
|---|---|
| public GlyphLayout. | |
| x | back to summary |
|---|---|
| public float x | |
| xAdvances | back to summary |
|---|---|
| public FloatArray xAdvances Contains glyphs.size+1 entries: | |
| y | back to summary |
|---|---|
| public float y | |
| GlyphRun | back to summary |
|---|---|
| public GlyphRun() | |
| appendRun | back to summary |
|---|---|
| pack-priv void appendRun(GlyphLayout. | |
| reset | back to summary |
|---|---|
| public void reset() Implements com. Doc from com. Resets the object for reuse. Object references should be nulled and fields may be set to default values. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| Modifier and Type | Field and Description |
|---|---|
| public static final GlyphLayout. | |
| public static final GlyphLayout. | |
| public static final GlyphLayout. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static GlyphLayout. | |
| public static GlyphLayout. |
| lastWrapped | back to summary |
|---|---|
| public static final GlyphLayout. | |
| notWrapped | back to summary |
|---|---|
| public static final GlyphLayout. | |
| wrapped | back to summary |
|---|---|
| public static final GlyphLayout. | |
| WrapState | back to summary |
|---|---|
| private WrapState() | |
| valueOf | back to summary |
|---|---|
| public static GlyphLayout. | |
| values | back to summary |
|---|---|
| public static GlyphLayout. | |