Package com.github.tommyettinger.textra
Class TextraLabel
java.lang.Object
com.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.github.tommyettinger.textra.TextraLabel
- All Implemented Interfaces:
com.badlogic.gdx.scenes.scene2d.utils.Layout
- Direct Known Subclasses:
TypingLabel
public class TextraLabel
extends com.badlogic.gdx.scenes.scene2d.ui.Widget
A scene2d.ui Widget that displays text using a
This is meant to work with
Font
rather than a libGDX BitmapFont. This supports being
laid out in a Table just like the typical Label (when wrap
is false, which is the default). This
permits square-bracket tag markup from Font, such as [light blue]
to change the font color, or [_]
to
underline text. It does not support the curly-brace token markup that its subclass TypingLabel
does, nor does
this handle input in the way TypingLabel can. It also, naturally, doesn't have the typing effect TypingLabel does,
which makes this more suitable for some kinds of text. TypingLabel can be told to immediately
TypingLabel.skipToTheEnd()
, which does make it look like a TextraLabel, but permits effects.
This is meant to work with
FWSkin
or one of its subclasses, such as FreeTypistSkin
, and isn't
guaranteed to work with a regular Skin
. FWSkin can load the same JSON files Skin uses, and it extends Skin.
If you encounter an unusually high amount of native memory being used, the cause is most likely Font objects being
created from BitmapFont objects repeatedly, which FWSkin is designed to avoid. When using any scene2d.ui
widget from TextraTypist with an FWSkin, the correct and optimal style from Styles
is used, and that avoids
creating more and more Font objects as widgets are created and destroyed. Subclasses of FWSkin are also perfectly
fine to use, such as the subclass in FreeTypist that allows
using FreeType to generate a Font from skin JSON configuration.
Using a regular libGDX Skin object, not an FWSkin, will be a problem.-
Field Summary
FieldsModifier and TypeFieldDescriptionint
protected Font
protected boolean
boolean
If true; allows text to wrap when it would go past the layout'stargetWidth
and continue on the next line; if false, uses a very long target width and only adds newlines when they are in the label's text. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a TextraLabel that uses the default libGDX font (lsans-15 in the current version) with white color.TextraLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin) Creates a TextraLabel with the given text (which may be multi-line) and using the specified Skin's LabelStyle.TextraLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, boolean makeGridGlyphs) Creates a TextraLabel with the given text (which may be multi-line) and using the specified Skin's LabelStyle.TextraLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, Font replacementFont) Creates a TextraLabel with the given text (which may be multi-line) and using the default style from a Skin, replacing any font that would be drawn from the style withreplacementFont
.TextraLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName) Creates a TextraLabel with the given text (which may be multi-line) and using the specified style from the given Skin.TextraLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, boolean makeGridGlyphs) Creates a TextraLabel with the given text (which may be multi-line) and using the specified style from the given Skin.TextraLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, com.badlogic.gdx.graphics.Color color) Creates a TextraLabel with the given text (which may be multi-line), using the specified style from the given Skin, with the default Color overridden by the given one.TextraLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, Font replacementFont) Creates a TextraLabel with the given text (which may be multi-line) and using the given style taken by name from a Skin, replacing any font that would be drawn from the style withreplacementFont
.TextraLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, Font replacementFont, com.badlogic.gdx.graphics.Color color) Creates a TextraLabel with the given text (which may be multi-line) and using the given style taken by name from a Skin, replacing any font that would be drawn from the style withreplacementFont
.TextraLabel
(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, String colorName) Creates a TextraLabel with the given text (which may be multi-line), using the specified style from the given Skin, with the default Color overridden by the color with the given name in the skin.TextraLabel
(String text, Font font) Creates a TextraLabel with the given text (which may be multi-line) and using the given Font.TextraLabel
(String text, Font font, com.badlogic.gdx.graphics.Color color) Creates a TextraLabel with the given text (which may be multi-line), using the given Font, and using the given default color.TextraLabel
(String text, Font font, com.badlogic.gdx.graphics.Color color, Justify justify) Creates a TextraLabel with the given text (which may be multi-line), using the given Font, and using the given default color.TextraLabel
(String text, Styles.LabelStyle style) Creates a TextraLabel with the given text (which may be multi-line) and using the given style.TextraLabel
(String text, Styles.LabelStyle style, boolean makeGridGlyphs) Creates a TextraLabel with the given text (which may be multi-line) and using the given style.TextraLabel
(String text, Styles.LabelStyle style, Font replacementFont) Creates a TextraLabel with the given text (which may be multi-line) and using the given style. -
Method Summary
Modifier and TypeMethodDescriptionvoid
draw
(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha) com.badlogic.gdx.utils.FloatArray
Contains one float per glyph; each is a multiplier that affects the x-advance of that glyph.int
Gets the alignment for the text in this TextraLabel.Gets the ellipsis, which may be null, or may be a String that can be placed at the end of the text if its max lines are exceeded.getFont()
long
getGlyph
(int index) float
getLineHeight
(int index) Gets the height of the Line containing the glyph at the given index.int
The maximum number ofLine
s this label can display.com.badlogic.gdx.utils.FloatArray
Contains two floats per glyph; even items are x offsets, odd items are y offsets.float
float
com.badlogic.gdx.utils.FloatArray
Contains one float per glyph; each is a rotation in degrees to apply to that glyph (around its center).com.badlogic.gdx.utils.FloatArray
Contains two floats per glyph, as size multipliers; even items apply to x, odd items apply to y.void
boolean
isWrap()
Gets the current wrapping mode.void
layout()
void
setAlignment
(int alignment) Sets the alignment for the text in this TextraLabel.void
setEllipsis
(String ellipsis) Sets the ellipsis text, which replaces the last few glyphs if non-null and the text added would exceed thegetMaxLines()
of this label's layout.void
Sets the font to the specified Font and then regenerates the layout usingFont.regenerateLayout(Layout)
.void
Just likesetFont(Font)
, except this only regenerates the layout ifregenerate
is true.void
setHeight
(float height) void
setMaxLines
(int maxLines) Sets the maximum number ofLine
s this Layout can display; this is always at least 1.protected void
setParent
(com.badlogic.gdx.scenes.scene2d.Group parent) Called by the framework when an actor is added to or removed from a group.void
setSize
(float width, float height) void
setStage
(com.badlogic.gdx.scenes.scene2d.Stage stage) Called by the framework when this actor or any ascendant is added to a group that is in the stage.void
setSuperHeight
(float height) This only exists so code that needs to useActor.setHeight(float)
still can, even with setHeight() implemented here.void
setSuperWidth
(float width) This only exists so code that needs to useActor.setWidth(float)
still can, even with setWidth() implemented here.void
Changes the text in this TextraLabel to the given String, parsing any markup in it.void
setWidth
(float width) setWrap
(boolean wrap) Sets the wrapping mode; if this changes the mode, then this invalidates the hierarchy.By default, does nothing; this is overridden in TypingLabel to skip its text progression ahead.substring
(int start, int end) Gets a String from the layout of this label, made of only the char portions of the glyphs from start (inclusive) to end (exclusive).toString()
useIntegerPositions
(boolean integer) A no-op unlessfont
is a subclass that overridesFont.handleIntegerPosition(float)
.void
validate()
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, sizeChanged
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
act, addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setTouchable, setUserObject, setVisible, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
-
Field Details
-
layout
-
font
-
align
public int align -
wrap
public boolean wrapIf true; allows text to wrap when it would go past the layout'stargetWidth
and continue on the next line; if false, uses a very long target width and only adds newlines when they are in the label's text. This should typically be false for widgets that use scene2d.ui layout, but should be true for any widget that dynamically adjusts to fill an area with wrapped text. -
storedText
-
style
-
prefSizeInvalid
protected boolean prefSizeInvalid
-
-
Constructor Details
-
TextraLabel
public TextraLabel()Creates a TextraLabel that uses the default libGDX font (lsans-15 in the current version) with white color. This allocates a new Font every time it is called, so you should avoid this constructor in code that is called more than a handful of times. Its only valid use is in debugging. -
TextraLabel
Creates a TextraLabel with the given text (which may be multi-line) and using the specified Skin's LabelStyle. The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered as "default"
-
TextraLabel
public TextraLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, boolean makeGridGlyphs) Creates a TextraLabel with the given text (which may be multi-line) and using the specified Skin's LabelStyle. The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered as "default"makeGridGlyphs
- currently ignored
-
TextraLabel
Creates a TextraLabel with the given text (which may be multi-line) and using the specified style from the given Skin. The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered with the given styleNamestyleName
- the name of a Styles.LabelStyle to use from the Skin
-
TextraLabel
public TextraLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, boolean makeGridGlyphs) Creates a TextraLabel with the given text (which may be multi-line) and using the specified style from the given Skin. The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered with the given styleNamestyleName
- the name of a Styles.LabelStyle to use from the SkinmakeGridGlyphs
- currently ignored
-
TextraLabel
public TextraLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, com.badlogic.gdx.graphics.Color color) Creates a TextraLabel with the given text (which may be multi-line), using the specified style from the given Skin, with the default Color overridden by the given one. The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered with the given styleNamestyleName
- the name of a Styles.LabelStyle to use from the Skincolor
- the color to use for the font when unspecified (at the start and when reset)
-
TextraLabel
public TextraLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, String colorName) Creates a TextraLabel with the given text (which may be multi-line), using the specified style from the given Skin, with the default Color overridden by the color with the given name in the skin. The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered with the given styleNamestyleName
- the name of a Styles.LabelStyle to use from the SkincolorName
- the name in the skin of the color to use for the font when unspecified (at the start and when reset)
-
TextraLabel
Creates a TextraLabel with the given text (which may be multi-line) and using the given style. This does not require a Skin to be available.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingstyle
- the Styles.LabelStyle to use
-
TextraLabel
Creates a TextraLabel with the given text (which may be multi-line) and using the given style. This does not require a Skin to be available.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingstyle
- the Styles.LabelStyle to usemakeGridGlyphs
- currently ignored
-
TextraLabel
Creates a TextraLabel with the given text (which may be multi-line) and using the default style from a Skin, replacing any font that would be drawn from the style withreplacementFont
. The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingskin
- the default Styles.LabelStyle will be obtained from this and usedreplacementFont
- a Font that will be used in place of the one in style
-
TextraLabel
public TextraLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, Font replacementFont) Creates a TextraLabel with the given text (which may be multi-line) and using the given style taken by name from a Skin, replacing any font that would be drawn from the style withreplacementFont
. The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered with the given styleNamestyleName
- the name of a Styles.LabelStyle to use from the SkinreplacementFont
- a Font that will be used in place of the one in style
-
TextraLabel
public TextraLabel(String text, com.badlogic.gdx.scenes.scene2d.ui.Skin skin, String styleName, Font replacementFont, com.badlogic.gdx.graphics.Color color) Creates a TextraLabel with the given text (which may be multi-line) and using the given style taken by name from a Skin, replacing any font that would be drawn from the style withreplacementFont
. The skin should almost certainly be anFWSkin
or one of its subclasses.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingskin
- almost always anFWSkin
or one of its subclasses; must have aStyles.LabelStyle
orLabel.LabelStyle
registered with the given styleNamestyleName
- the name of a Styles.LabelStyle to use from the SkinreplacementFont
- a Font that will be used in place of the one in stylecolor
- the base color to use for the label, used when reset
-
TextraLabel
Creates a TextraLabel with the given text (which may be multi-line) and using the given style. This does not require a Skin to be available.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingstyle
- the Styles.LabelStyle to use, except for its fontreplacementFont
- a Font that will be used in place of the one in style
-
TextraLabel
Creates a TextraLabel with the given text (which may be multi-line) and using the given Font. This does not require a Skin to be available.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingfont
- a Font from this library, such as one obtained fromKnownFonts
-
TextraLabel
Creates a TextraLabel with the given text (which may be multi-line), using the given Font, and using the given default color. This does not require a Skin to be available.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingfont
- a Font from this library, such as one obtained fromKnownFonts
color
- the color to use for the font when unspecified (at the start and when reset)
-
TextraLabel
Creates a TextraLabel with the given text (which may be multi-line), using the given Font, and using the given default color. This does not require a Skin to be available.- Parameters:
text
- the text to use; may be multi-line, but will default to not wrappingfont
- a Font from this library, such as one obtained fromKnownFonts
color
- the color to use for the font when unspecified (at the start and when reset)
-
-
Method Details
-
draw
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha) - Overrides:
draw
in classcom.badlogic.gdx.scenes.scene2d.ui.Widget
-
getPrefWidth
public float getPrefWidth()- Specified by:
getPrefWidth
in interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout
- Overrides:
getPrefWidth
in classcom.badlogic.gdx.scenes.scene2d.ui.Widget
-
getPrefHeight
public float getPrefHeight()- Specified by:
getPrefHeight
in interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout
- Overrides:
getPrefHeight
in classcom.badlogic.gdx.scenes.scene2d.ui.Widget
-
useIntegerPositions
A no-op unlessfont
is a subclass that overridesFont.handleIntegerPosition(float)
.- Parameters:
integer
- usually ignored- Returns:
- this for chaining
-
isWrap
public boolean isWrap()Gets the current wrapping mode. When wrap is enabled, the preferred and/or min/max sizes must be used so this knows where to wrap. If wrap is disabled, lines that are too wide will just widen the size of the widget.- Returns:
- whether this is currently wrapping
-
setWrap
Sets the wrapping mode; if this changes the mode, then this invalidates the hierarchy. When wrap is enabled, the preferred and/or min/max sizes must be used so this knows where to wrap. If wrap is disabled, lines that are too wide will just widen the size of the widget. This also callslayout()
if wrap becomes enabled because of this call, because much of the behavior of layout() depends on wrap's value, then callssetText(String)
with the stored text content to ensure text obeys the wrapping rules.- Parameters:
wrap
- whether to wrap or not
-
setWidth
public void setWidth(float width) - Overrides:
setWidth
in classcom.badlogic.gdx.scenes.scene2d.Actor
-
setHeight
public void setHeight(float height) - Overrides:
setHeight
in classcom.badlogic.gdx.scenes.scene2d.Actor
-
setSize
public void setSize(float width, float height) - Overrides:
setSize
in classcom.badlogic.gdx.scenes.scene2d.Actor
-
setSuperWidth
public void setSuperWidth(float width) This only exists so code that needs to useActor.setWidth(float)
still can, even with setWidth() implemented here.- Parameters:
width
- the new width, in world units as a float
-
setSuperHeight
public void setSuperHeight(float height) This only exists so code that needs to useActor.setHeight(float)
still can, even with setHeight() implemented here.- Parameters:
height
- the new height, in world units as a float
-
layout
public void layout()- Specified by:
layout
in interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout
- Overrides:
layout
in classcom.badlogic.gdx.scenes.scene2d.ui.Widget
-
getAlignment
public int getAlignment()Gets the alignment for the text in this TextraLabel. This is a constant inAlign
.- Returns:
- the alignment used by this TextraLabel, as a constant from
Align
- See Also:
-
Align
-
setAlignment
public void setAlignment(int alignment) Sets the alignment for the text in this TextraLabel.- Parameters:
alignment
- a constant fromAlign
- See Also:
-
Align
-
getFont
-
setFont
Sets the font to the specified Font and then regenerates the layout usingFont.regenerateLayout(Layout)
. This is equivalent to callingsetFont(Font, boolean)
with true for regenerate. This won't regenerate the layout if the given font is equal to the current font for this TextraLabel.- Parameters:
font
- the non-null font to use for this TextraLabel
-
setFont
Just likesetFont(Font)
, except this only regenerates the layout ifregenerate
is true. (To contrast,setFont(Font)
always regenerates the layout.) This won't regenerate the layout if the given font is equal to the current font for this TextraLabel.- Parameters:
font
- the non-null font to use for this TextraLabelregenerate
- if true, the layout will be re-wrapped and its size re-calculated for the new font
-
setText
Changes the text in this TextraLabel to the given String, parsing any markup in it.- Parameters:
markupText
- a String that can contain Font markup
-
skipToTheEnd
By default, does nothing; this is overridden in TypingLabel to skip its text progression ahead. -
invalidate
public void invalidate()- Specified by:
invalidate
in interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout
- Overrides:
invalidate
in classcom.badlogic.gdx.scenes.scene2d.ui.Widget
-
validate
public void validate()- Specified by:
validate
in interfacecom.badlogic.gdx.scenes.scene2d.utils.Layout
- Overrides:
validate
in classcom.badlogic.gdx.scenes.scene2d.ui.Widget
-
setStage
public void setStage(com.badlogic.gdx.scenes.scene2d.Stage stage) Called by the framework when this actor or any ascendant is added to a group that is in the stage. This is overridden as public instead of protected because most of its usage in scene2d.ui code is not actually in inheriting classes, but in other classes in the same package. That's a problem here, so we make it public.- Overrides:
setStage
in classcom.badlogic.gdx.scenes.scene2d.Actor
- Parameters:
stage
- May be null if the actor or any ascendant is no longer in a stage.
-
setParent
protected void setParent(com.badlogic.gdx.scenes.scene2d.Group parent) Called by the framework when an actor is added to or removed from a group. This is overridden as public instead of protected because most of its usage in scene2d.ui code is not actually in inheriting classes, but in other classes in the same package. That's a problem here, so we make it public.- Overrides:
setParent
in classcom.badlogic.gdx.scenes.scene2d.Actor
- Parameters:
parent
- May be null if the actor has been removed from the parent.
-
toString
- Overrides:
toString
in classcom.badlogic.gdx.scenes.scene2d.Actor
-
getGlyph
public long getGlyph(int index) Gets a glyph from this label'slayout
, where a glyph is along
encoded howFont
uses it. In a TextraLabel, this is effectively equivalent toTypingLabel.getInWorkingLayout(int)
, but it may be different from that method in a TypingLabel, depending on word wrap.- Parameters:
index
- the 0-based index of the glyph to retrieve- Returns:
- the glyph, if it was found, or 16777215 (0xFFFFFF in hexadecimal) if the index was out of bounds
-
getMaxLines
public int getMaxLines()The maximum number ofLine
s this label can display.- Returns:
- the maximum number of
Line
objects this label can display
-
setMaxLines
public void setMaxLines(int maxLines) Sets the maximum number ofLine
s this Layout can display; this is always at least 1. For effectively unlimited lines, passInteger.MAX_VALUE
to this.- Parameters:
maxLines
- the limit for how many Line objects this Layout can display; always 1 or more
-
getEllipsis
Gets the ellipsis, which may be null, or may be a String that can be placed at the end of the text if its max lines are exceeded.- Returns:
- an ellipsis String or null
-
setEllipsis
Sets the ellipsis text, which replaces the last few glyphs if non-null and the text added would exceed thegetMaxLines()
of this label's layout. For the ellipsis to appear, this has to be called with a non-null String (often"..."
, or"…"
if the font supports it), andsetMaxLines(int)
needs to have been called with a small enough number, such as 1.- Parameters:
ellipsis
- a String for a Layout to end with if its max lines are exceeded, or null to avoid such truncation
-
substring
Gets a String from the layout of this label, made of only the char portions of the glyphs from start (inclusive) to end (exclusive). This can retrieve text from across multiple lines.- Parameters:
start
- inclusive start indexend
- exclusive end index- Returns:
- a String made of only the char portions of the glyphs from start to end
-
getLineHeight
public float getLineHeight(int index) Gets the height of the Line containing the glyph at the given index. If the index is out of bounds, this just returnsFont.cellHeight
.- Parameters:
index
- the 0-based index of the glyph to measure- Returns:
- the height of the Line containing the specified glyph
-
getRotations
public com.badlogic.gdx.utils.FloatArray getRotations()Contains one float per glyph; each is a rotation in degrees to apply to that glyph (around its center). This should not be confused withActor.getRotation()
, which refers to the rotation of the label itself. This getter accesses the rotation of each glyph around its center instead. This is a direct reference to the currentlayout
'sLayout.rotations
. -
getOffsets
public com.badlogic.gdx.utils.FloatArray getOffsets()Contains two floats per glyph; even items are x offsets, odd items are y offsets. This getter accesses the x- and y-offsets of each glyph from its normal position. This is a direct reference to the currentlayout
'sLayout.offsets
. -
getSizing
public com.badlogic.gdx.utils.FloatArray getSizing()Contains two floats per glyph, as size multipliers; even items apply to x, odd items apply to y. This getter accesses the x-and y-scaling of each glyph in its normal location, without changing line height or the x-advance of each glyph. It is usually meant for temporary or changing effects, not permanent scaling. This is a direct reference to the currentlayout
'sLayout.sizing
. -
getAdvances
public com.badlogic.gdx.utils.FloatArray getAdvances()Contains one float per glyph; each is a multiplier that affects the x-advance of that glyph. This getter uses the same types of values asgetSizing()
, so if you change the x-scaling of a glyph with that variable, you can also change its x-advance here by assigning the same value for that glyph here. This is a direct reference to the currentlayout
'sLayout.rotations
.
-