Package gaiasky.util.gdx.g2d
Class BitmapFont.BitmapFontData
java.lang.Object
gaiasky.util.gdx.g2d.BitmapFont.BitmapFontData
- Enclosing class:
- BitmapFont
Backing data for a
BitmapFont
.-
Field Summary
Modifier and TypeFieldDescriptionfloat
The distance from the cap height to the top of the tallest glyph.float
Multiplier for the line height of blank lines.char[]
Additional characters besides whitespace where text is wrapped.char[]
float
The distance from the top of most uppercase characters to the baseline.float
The amount to add to the glyph X position when drawing a cursor between glyphs.float
The distance from the bottom of the glyph that extends the lowest to the baseline.float
The distance to move down when \n is encountered.boolean
com.badlogic.gdx.files.FileHandle
final BitmapFont.Glyph[][]
String[]
An array of the image paths, for multiple texture pages.float
The distance from one line of text to the next.boolean
The glyph to display for characters not in the font.float
float
float
float
float
float
float
The width of the space character.char[]
float
The x-height, which is the distance from the top of most lowercase characters to the baseline. -
Constructor Summary
ConstructorDescriptionCreates an empty BitmapFontData for configuration before callingload(FileHandle, boolean)
, to subclass, or to populate yourself, e.g.BitmapFontData
(com.badlogic.gdx.files.FileHandle fontFile, boolean flip) -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.files.FileHandle
getGlyph
(char ch) Returns the glyph for the specified character, or null if no such glyph exists.void
getGlyphs
(GlyphLayout.GlyphRun run, CharSequence str, int start, int end, BitmapFont.Glyph lastGlyph) Using the specified string, populates the glyphs and positions of the specified glyph run.getImagePath
(int index) Returns the image path for the texture page at the given index (the "id" in the BMFont file).String[]
int
getWrapIndex
(com.badlogic.gdx.utils.Array<BitmapFont.Glyph> glyphs, int start) Returns the first valid glyph index to use to wrap to the next line, starting at the specified start index and (typically) moving toward the beginning of the glyphs array.boolean
hasGlyph
(char ch) Returns true if the font has the glyph, or if the font has amissingGlyph
.boolean
isBreakChar
(char c) boolean
isWhitespace
(char c) void
load
(com.badlogic.gdx.files.FileHandle fontFile, boolean flip) void
scale
(float amount) Sets the font's scale relative to the current scale.void
setGlyph
(int ch, BitmapFont.Glyph glyph) void
setGlyphRegion
(BitmapFont.Glyph glyph, TextureRegion region) void
setLineHeight
(float height) Sets the line height, which is the distance from one line of text to the next.void
setScale
(float scaleXY) Scales the font by the specified amount in both directions.void
setScale
(float scaleX, float scaleY) Scales the font by the specified amounts on both axes
-
Field Details
-
glyphs
-
imagePaths
An array of the image paths, for multiple texture pages. -
fontFile
public com.badlogic.gdx.files.FileHandle fontFile -
flipped
public boolean flipped -
padTop
public float padTop -
padRight
public float padRight -
padBottom
public float padBottom -
padLeft
public float padLeft -
lineHeight
public float lineHeightThe distance from one line of text to the next. To set this value, usesetLineHeight(float)
. -
capHeight
public float capHeightThe distance from the top of most uppercase characters to the baseline. Since the drawing position is the cap height of the first line, the cap height can be used to get the location of the baseline. -
ascent
public float ascentThe distance from the cap height to the top of the tallest glyph. -
descent
public float descentThe distance from the bottom of the glyph that extends the lowest to the baseline. This number is negative. -
down
public float downThe distance to move down when \n is encountered. -
blankLineScale
public float blankLineScaleMultiplier for the line height of blank lines. down * blankLineHeight is used as the distance to move down for a blank line. -
scaleX
public float scaleX -
scaleY
public float scaleY -
markupEnabled
public boolean markupEnabled -
cursorX
public float cursorXThe amount to add to the glyph X position when drawing a cursor between glyphs. This field is not set by the BMFont file, it needs to be set manually depending on how the glyphs are rendered on the backing textures. -
missingGlyph
The glyph to display for characters not in the font. May be null. -
spaceXadvance
public float spaceXadvanceThe width of the space character. -
xHeight
public float xHeightThe x-height, which is the distance from the top of most lowercase characters to the baseline. -
breakChars
public char[] breakCharsAdditional characters besides whitespace where text is wrapped. Eg, a hyphen (-). -
xChars
public char[] xChars -
capChars
public char[] capChars
-
-
Constructor Details
-
BitmapFontData
public BitmapFontData()Creates an empty BitmapFontData for configuration before callingload(FileHandle, boolean)
, to subclass, or to populate yourself, e.g. using stb-truetype or FreeType. -
BitmapFontData
public BitmapFontData(com.badlogic.gdx.files.FileHandle fontFile, boolean flip)
-
-
Method Details
-
load
public void load(com.badlogic.gdx.files.FileHandle fontFile, boolean flip) -
setGlyphRegion
-
setLineHeight
public void setLineHeight(float height) Sets the line height, which is the distance from one line of text to the next. -
setGlyph
-
getFirstGlyph
-
hasGlyph
public boolean hasGlyph(char ch) Returns true if the font has the glyph, or if the font has amissingGlyph
. -
getGlyph
Returns the glyph for the specified character, or null if no such glyph exists. Note thatgetGlyphs(GlyphRun, CharSequence, int, int, Glyph)
should be be used to shape a string of characters into a list of glyphs. -
getGlyphs
public void getGlyphs(GlyphLayout.GlyphRun run, CharSequence str, int start, int end, BitmapFont.Glyph lastGlyph) Using the specified string, populates the glyphs and positions of the specified glyph run.- Parameters:
str
- Characters to convert to glyphs. Will not contain newline or color tags. May contain "[[" for an escaped left square bracket.lastGlyph
- The glyph immediately before this run, or null if this is run is the first on a line of text.
-
getWrapIndex
Returns the first valid glyph index to use to wrap to the next line, starting at the specified start index and (typically) moving toward the beginning of the glyphs array. -
isBreakChar
public boolean isBreakChar(char c) -
isWhitespace
public boolean isWhitespace(char c) -
getImagePath
Returns the image path for the texture page at the given index (the "id" in the BMFont file). -
getImagePaths
-
getFontFile
public com.badlogic.gdx.files.FileHandle getFontFile() -
setScale
public void setScale(float scaleX, float scaleY) Scales the font by the specified amounts on both axesNote that smoother scaling can be achieved if the texture backing the BitmapFont is using
Texture.TextureFilter.Linear
. The default is Nearest, so use a BitmapFont constructor that takes aTextureRegion
.- Throws:
IllegalArgumentException
- if scaleX or scaleY is zero.
-
setScale
public void setScale(float scaleXY) Scales the font by the specified amount in both directions.- Throws:
IllegalArgumentException
- if scaleX or scaleY is zero.- See Also:
-
scale
public void scale(float amount) Sets the font's scale relative to the current scale.- Throws:
IllegalArgumentException
- if the resulting scale is zero.- See Also:
-