APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.badlogic.gdx.graphics.g2d

public Class BitmapFont

extends Object
implements Disposable
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.utils.Disposable
Known Direct Subclasses
com.badlogic.gdx.graphics.g2d.DistanceFieldFont
Imports
java.io.BufferedReader, .InputStreamReader, java.util.StringTokenizer, java.util.regex.Matcher, .Pattern, com.badlogic.gdx.Gdx, com.badlogic.gdx.files.FileHandle, com.badlogic.gdx.graphics.Color, .Texture, .Texture.TextureFilter, com.badlogic.gdx.graphics.g2d.GlyphLayout.GlyphRun, .TextureAtlas.AtlasRegion, com.badlogic.gdx.utils.Array, .Disposable, .FloatArray, .GdxRuntimeException, .StreamUtils

Renders bitmap fonts. The font consists of 2 files: an image file or TextureRegion containing the glyphs and a file in the AngleCode BMFont text format that describes where each glyph is on the image.

Text is drawn using a Batch. Text can be cached in a BitmapFontCache for faster rendering of static text, which saves needing to compute the location of each glyph each frame.

* The texture for a BitmapFont loaded from a file is managed. dispose() must be called to free the texture when no longer needed. A BitmapFont loaded using a TextureRegion is managed if the region's texture is managed. Disposing the BitmapFont disposes the region's texture, which may not be desirable if the texture is still being used elsewhere.

The code was originally based on Matthias Mann's TWL BitmapFont class. Thanks for sharing, Matthias! :)

Authors
Nathan Sweet, Matthias Mann

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
BitmapFont.Glyph

Represents a single character in a font page.

Field Summary

Modifier and TypeField and Description
private final BitmapFontCache
pack-priv final BitmapFont.BitmapFontData
private boolean
pack-priv boolean
private static final int
private boolean
private static final int
private static final int
pack-priv Array<TextureRegion>

Constructor Summary

AccessConstructor and Description
public
BitmapFont()

Creates a BitmapFont using the default 15pt Liberation Sans font included in the libgdx JAR file.

public
BitmapFont(boolean
If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.
flip
)

Creates a BitmapFont using the default 15pt Liberation Sans font included in the libgdx JAR file.

public
BitmapFont(FileHandle
the font definition file
fontFile
,
TextureRegion
The texture region containing the glyphs. The glyphs must be relative to the lower left corner (ie, the region should not be flipped). If the region is null the glyph images are loaded from the image path in the font file.
region
)

Creates a BitmapFont with the glyphs relative to the specified region.

public
BitmapFont(FileHandle fontFile, TextureRegion
The texture region containing the glyphs. The glyphs must be relative to the lower left corner (ie, the region should not be flipped). If the region is null the glyph images are loaded from the image path in the font file.
region
,
boolean
If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.
flip
)

Creates a BitmapFont with the glyphs relative to the specified region.

public
BitmapFont(FileHandle fontFile)

Creates a BitmapFont from a BMFont file.

public
BitmapFont(FileHandle fontFile, boolean
If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.
flip
)

Creates a BitmapFont from a BMFont file.

public
BitmapFont(FileHandle fontFile, FileHandle imageFile, boolean
If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.
flip
)

Creates a BitmapFont from a BMFont file, using the specified image for glyphs.

public
BitmapFont(FileHandle fontFile, FileHandle imageFile, boolean
If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.
flip
,
boolean
If true, rendering positions will be at integer values to avoid filtering artifacts.
integer
)

Creates a BitmapFont from a BMFont file, using the specified image for glyphs.

public
BitmapFont(BitmapFont.BitmapFontData data, TextureRegion region, boolean
If true, rendering positions will be at integer values to avoid filtering artifacts.
integer
)

Constructs a new BitmapFont from the given BitmapFontData and TextureRegion.

public
BitmapFont(BitmapFont.BitmapFontData data, Array<TextureRegion> pageRegions, boolean
If true, rendering positions will be at integer values to avoid filtering artifacts.
integer
)

Constructs a new BitmapFont from the given BitmapFontData and array of TextureRegion.

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Disposes the texture used by this BitmapFont's region IF this BitmapFont created the texture.

public GlyphLayout
draw(Batch batch, CharSequence str, float x, float y)

Draws text at the specified position.

public GlyphLayout
draw(Batch batch, CharSequence str, float x, float y, float targetWidth, int halign, boolean wrap)

Draws text at the specified position.

public GlyphLayout
draw(Batch batch, CharSequence str, float x, float y, int start, int end, float targetWidth, int halign, boolean wrap)

Draws text at the specified position.

public GlyphLayout
draw(Batch batch, CharSequence str, float x, float y, int start, int end, float targetWidth, int halign, boolean wrap, String truncate)

Draws text at the specified position.

public void
draw(Batch batch, GlyphLayout layout, float x, float y)

Draws text at the specified position.

public float
getAscent()

Returns the ascent, which is the distance from the cap height to the top of the tallest glyph.

public BitmapFontCache

Returns:

the bitmap font cache used by this font
getCache
()

For expert usage -- returns the BitmapFontCache used by this font, for rendering to a sprite batch.

public float
getCapHeight()

Returns the cap height, which is the distance from the top of most uppercase characters to the baseline.

public Color
getColor()

Returns the color of text drawn with this font.

public BitmapFont.BitmapFontData
getData()

Gets the underlying BitmapFontData for this BitmapFont.

public float
getDescent()

Returns the descent, which is the distance from the bottom of the glyph that extends the lowest to the baseline.

public float
getLineHeight()

Returns the line height, which is the distance from one line of text to the next.

public TextureRegion

Returns:

the first texture region
getRegion
()

Returns the first texture region.

public TextureRegion

Returns:

the texture page at the given index
getRegion
(int index)

Returns the texture page at the given index.

public Array<TextureRegion>

Returns:

the array of texture regions; modifying it may produce undesirable results
getRegions
()

Returns the array of TextureRegions that represents each texture page of glyphs.

public float
public float
public float
getSpaceXadvance()

Returns the x-advance of the space character.

public float
getXHeight()

Returns the x-height, which is the distance from the top of most lowercase characters to the baseline.

pack-priv static int
indexOf(CharSequence text, char ch, int start)

public boolean
isFlipped()

Returns true if this BitmapFont has been flipped for use with a y-down coordinate system.

protected void
public BitmapFontCache
newFontCache()

Creates a new BitmapFontCache for this font.

public boolean
ownsTexture()

Returns: whether the texture is owned by the font, font disposes the texture itself if true

public void
setColor(Color color)

A convenience method for setting the font color.

public void
setColor(float r, float g, float b, float a)

A convenience method for setting the font color.

public void
setFixedWidthGlyphs(CharSequence glyphs)

Makes the specified glyphs fixed width.

public void
setOwnsTexture(boolean
whether the font owns the texture
ownsTexture
)

Sets whether the font owns the texture.

public void
setUseIntegerPositions(boolean integer)

Specifies whether to use integer positions.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public boolean
usesIntegerPositions()

Checks whether this font uses integer positions for drawing.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cacheback to summary
private final BitmapFontCache cache
databack to summary
pack-priv final BitmapFont.BitmapFontData data
flippedback to summary
private boolean flipped
integerback to summary
pack-priv boolean integer
LOG2_PAGE_SIZEback to summary
private static final int LOG2_PAGE_SIZE
ownsTextureback to summary
private boolean ownsTexture
PAGE_SIZEback to summary
private static final int PAGE_SIZE
PAGESback to summary
private static final int PAGES
regionsback to summary
pack-priv Array<TextureRegion> regions

Constructor Detail

BitmapFontback to summary
public BitmapFont()

Creates a BitmapFont using the default 15pt Liberation Sans font included in the libgdx JAR file. This is convenient to easily display text without bothering without generating a bitmap font yourself.

BitmapFontback to summary
public BitmapFont(boolean flip)

Creates a BitmapFont using the default 15pt Liberation Sans font included in the libgdx JAR file. This is convenient to easily display text without bothering without generating a bitmap font yourself.

Parameters
flip:boolean

If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.

BitmapFontback to summary
public BitmapFont(FileHandle fontFile, TextureRegion region)

Creates a BitmapFont with the glyphs relative to the specified region. If the region is null, the glyph textures are loaded from the image file given in the font file. The dispose() method will not dispose the region's texture in this case!

The font data is not flipped.

Parameters
fontFile:FileHandle

the font definition file

region:TextureRegion

The texture region containing the glyphs. The glyphs must be relative to the lower left corner (ie, the region should not be flipped). If the region is null the glyph images are loaded from the image path in the font file.

BitmapFontback to summary
public BitmapFont(FileHandle fontFile, TextureRegion region, boolean flip)

Creates a BitmapFont with the glyphs relative to the specified region. If the region is null, the glyph textures are loaded from the image file given in the font file. The dispose() method will not dispose the region's texture in this case!

Parameters
region:TextureRegion

The texture region containing the glyphs. The glyphs must be relative to the lower left corner (ie, the region should not be flipped). If the region is null the glyph images are loaded from the image path in the font file.

flip:boolean

If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.

BitmapFontback to summary
public BitmapFont(FileHandle fontFile)

Creates a BitmapFont from a BMFont file. The image file name is read from the BMFont file and the image is loaded from the same directory. The font data is not flipped.

BitmapFontback to summary
public BitmapFont(FileHandle fontFile, boolean flip)

Creates a BitmapFont from a BMFont file. The image file name is read from the BMFont file and the image is loaded from the same directory.

Parameters
flip:boolean

If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.

BitmapFontback to summary
public BitmapFont(FileHandle fontFile, FileHandle imageFile, boolean flip)

Creates a BitmapFont from a BMFont file, using the specified image for glyphs. Any image specified in the BMFont file is ignored.

Parameters
flip:boolean

If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.

BitmapFontback to summary
public BitmapFont(FileHandle fontFile, FileHandle imageFile, boolean flip, boolean integer)

Creates a BitmapFont from a BMFont file, using the specified image for glyphs. Any image specified in the BMFont file is ignored.

Parameters
flip:boolean

If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.

integer:boolean

If true, rendering positions will be at integer values to avoid filtering artifacts.

BitmapFontback to summary
public BitmapFont(BitmapFont.BitmapFontData data, TextureRegion region, boolean integer)

Constructs a new BitmapFont from the given BitmapFontData and TextureRegion. If the TextureRegion is null, the image path(s) will be read from the BitmapFontData. The dispose() method will not dispose the texture of the region(s) if the region is != null.

Passing a single TextureRegion assumes that your font only needs a single texture page. If you need to support multiple pages, either let the Font read the images themselves (by specifying null as the TextureRegion), or by specifying each page manually with the TextureRegion[] constructor.

Parameters
integer:boolean

If true, rendering positions will be at integer values to avoid filtering artifacts.

BitmapFontback to summary
public BitmapFont(BitmapFont.BitmapFontData data, Array<TextureRegion> pageRegions, boolean integer)

Constructs a new BitmapFont from the given BitmapFontData and array of TextureRegion. If the TextureRegion is null or empty, the image path(s) will be read from the BitmapFontData. The dispose() method will not dispose the texture of the region(s) if the regions array is != null and not empty.

Parameters
integer:boolean

If true, rendering positions will be at integer values to avoid filtering artifacts.

Method Detail

disposeback to summary
public void dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Disposes the texture used by this BitmapFont's region IF this BitmapFont created the texture.

drawback to summary
public GlyphLayout draw(Batch batch, CharSequence str, float x, float y)

Draws text at the specified position.

See Also
BitmapFontCache#addText(CharSequence, float, float)
drawback to summary
public GlyphLayout draw(Batch batch, CharSequence str, float x, float y, float targetWidth, int halign, boolean wrap)

Draws text at the specified position.

See Also
BitmapFontCache#addText(CharSequence, float, float, int, int, float, int, boolean, String)
drawback to summary
public GlyphLayout draw(Batch batch, CharSequence str, float x, float y, int start, int end, float targetWidth, int halign, boolean wrap)

Draws text at the specified position.

See Also
BitmapFontCache#addText(CharSequence, float, float, int, int, float, int, boolean, String)
drawback to summary
public GlyphLayout draw(Batch batch, CharSequence str, float x, float y, int start, int end, float targetWidth, int halign, boolean wrap, String truncate)

Draws text at the specified position.

See Also
BitmapFontCache#addText(CharSequence, float, float, int, int, float, int, boolean, String)
drawback to summary
public void draw(Batch batch, GlyphLayout layout, float x, float y)

Draws text at the specified position.

See Also
BitmapFontCache#addText(CharSequence, float, float, int, int, float, int, boolean, String)
getAscentback to summary
public float getAscent()

Returns the ascent, which is the distance from the cap height to the top of the tallest glyph.

getCacheback to summary
public BitmapFontCache getCache()

For expert usage -- returns the BitmapFontCache used by this font, for rendering to a sprite batch. This can be used, for example, to manipulate glyph colors within a specific index.

Returns:BitmapFontCache

the bitmap font cache used by this font

getCapHeightback to summary
public float getCapHeight()

Returns the cap height, which is the 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.

getColorback to summary
public Color getColor()

Returns the color of text drawn with this font.

getDataback to summary
public BitmapFont.BitmapFontData getData()

Gets the underlying BitmapFontData for this BitmapFont.

getDescentback to summary
public float getDescent()

Returns the descent, which is the distance from the bottom of the glyph that extends the lowest to the baseline. This number is negative.

getLineHeightback to summary
public float getLineHeight()

Returns the line height, which is the distance from one line of text to the next.

getRegionback to summary
public TextureRegion getRegion()

Returns the first texture region. This is included for backwards compatibility, and for convenience since most fonts only use one texture page. For multi-page fonts, use getRegions().

Returns:TextureRegion

the first texture region

getRegionback to summary
public TextureRegion getRegion(int index)

Returns the texture page at the given index.

Returns:TextureRegion

the texture page at the given index

getRegionsback to summary
public Array<TextureRegion> getRegions()

Returns the array of TextureRegions that represents each texture page of glyphs.

Returns:Array<TextureRegion>

the array of texture regions; modifying it may produce undesirable results

getScaleXback to summary
public float getScaleX()
getScaleYback to summary
public float getScaleY()
getSpaceXadvanceback to summary
public float getSpaceXadvance()

Returns the x-advance of the space character.

getXHeightback to summary
public float getXHeight()

Returns the x-height, which is the distance from the top of most lowercase characters to the baseline.

indexOfback to summary
pack-priv static int indexOf(CharSequence text, char ch, int start)
isFlippedback to summary
public boolean isFlipped()

Returns true if this BitmapFont has been flipped for use with a y-down coordinate system.

loadback to summary
protected void load(BitmapFont.BitmapFontData data)
newFontCacheback to summary
public BitmapFontCache newFontCache()

Creates a new BitmapFontCache for this font. Using this method allows the font to provide the BitmapFontCache implementation to customize rendering.

Note this method is called by the BitmapFont constructors. If a subclass overrides this method, it will be called before the subclass constructors.

ownsTextureback to summary
public boolean ownsTexture()
Returns:boolean

whether the texture is owned by the font, font disposes the texture itself if true

setColorback to summary
public void setColor(Color color)

A convenience method for setting the font color. The color can also be set by modifying getColor().

setColorback to summary
public void setColor(float r, float g, float b, float a)

A convenience method for setting the font color. The color can also be set by modifying getColor().

setFixedWidthGlyphsback to summary
public void setFixedWidthGlyphs(CharSequence glyphs)

Makes the specified glyphs fixed width. This can be useful to make the numbers in a font fixed width. Eg, when horizontally centering a score or loading percentage text, it will not jump around as different numbers are shown.

setOwnsTextureback to summary
public void setOwnsTexture(boolean ownsTexture)

Sets whether the font owns the texture. In case it does, the font will also dispose of the texture when dispose() is called. Use with care!

Parameters
ownsTexture:boolean

whether the font owns the texture

setUseIntegerPositionsback to summary
public void setUseIntegerPositions(boolean integer)

Specifies whether to use integer positions. Default is to use them so filtering doesn't kick in as badly.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

usesIntegerPositionsback to summary
public boolean usesIntegerPositions()

Checks whether this font uses integer positions for drawing.

com.badlogic.gdx.graphics.g2d back to summary

public Class BitmapFont.BitmapFontData

extends Object
Class Inheritance

Backing data for a BitmapFont.

Field Summary

Modifier and TypeField and Description
public float
ascent

The distance from the cap height to the top of the tallest glyph.

public float
blankLineScale

Multiplier for the line height of blank lines.

public char[]
breakChars

Additional characters besides whitespace where text is wrapped.

public char[]
public float
capHeight

The distance from the top of most uppercase characters to the baseline.

public float
cursorX

The amount to add to the glyph X position when drawing a cursor between glyphs.

public float
descent

The distance from the baseline to the bottom of the glyph that extends the lowest.

public float
down

The distance to move down when \n is encountered.

public boolean
public FileHandle
public final BitmapFont.Glyph[][]
public String[]
imagePaths

An array of the image paths, for multiple texture pages.

public float
lineHeight

The distance from one line of text to the next.

public boolean
public BitmapFont.Glyph
missingGlyph

The glyph to display for characters not in the font.

public String
name

The name of the font, or null.

public float
public float
public float
public float
public float
public float
public float
spaceXadvance

The width of the space character.

public char[]
public float
xHeight

The x-height, which is the distance from the top of most lowercase characters to the baseline.

Constructor Summary

AccessConstructor and Description
public
BitmapFontData()

Creates an empty BitmapFontData for configuration before calling load(FileHandle, boolean), to subclass, or to populate yourself, e.g. using stb-truetype or FreeType.

public
BitmapFontData(FileHandle fontFile, boolean flip)

Method Summary

Modifier and TypeMethod and Description
public BitmapFont.Glyph
public FileHandle
public BitmapFont.Glyph
getGlyph(char ch)

Returns the glyph for the specified character, or null if no such glyph exists.

public void
getGlyphs(GlyphLayout.GlyphRun run, CharSequence
Characters to convert to glyphs. Will not contain newline or color tags. May contain "[[" for an escaped left square bracket.
str
,
int start, int end, BitmapFont.Glyph
The glyph immediately before this run, or null if this is run is the first on a line of text. Used tp apply kerning between the specified glyph and the first glyph in this run.
lastGlyph
)

Using the specified string, populates the glyphs and positions of the specified glyph run.

public String
getImagePath(int index)

Returns the image path for the texture page at the given index (the "id" in the BMFont file).

public String[]
public int
getWrapIndex(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.

public boolean
hasGlyph(char ch)

Returns true if the font has the glyph, or if the font has a missingGlyph.

public boolean
isBreakChar(char c)

public boolean
isWhitespace(char c)

public void
load(FileHandle fontFile, boolean flip)

public void
scale(float amount)

Sets the font's scale relative to the current scale.

public void
setGlyph(int ch, BitmapFont.Glyph glyph)

public void
public void
setLineHeight(float height)

Sets the line height, which is the distance from one line of text to the next.

public void
setScale(float scaleX, float scaleY)

Scales the font by the specified amounts on both axes

Note that smoother scaling can be achieved if the texture backing the BitmapFont is using TextureFilter#Linear.

public void
setScale(float scaleXY)

Scales the font by the specified amount in both directions.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ascentback to summary
public float ascent

The distance from the cap height to the top of the tallest glyph.

blankLineScaleback to summary
public float blankLineScale

Multiplier for the line height of blank lines. down * blankLineHeight is used as the distance to move down for a blank line.

breakCharsback to summary
public char[] breakChars

Additional characters besides whitespace where text is wrapped. Eg, a hypen (-).

capCharsback to summary
public char[] capChars
capHeightback to summary
public float capHeight

The 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.

cursorXback to summary
public float cursorX

The 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.

descentback to summary
public float descent

The distance from the baseline to the bottom of the glyph that extends the lowest. This number is negative.

downback to summary
public float down

The distance to move down when \n is encountered.

flippedback to summary
public boolean flipped
fontFileback to summary
public FileHandle fontFile
glyphsback to summary
public final BitmapFont.Glyph[][] glyphs
imagePathsback to summary
public String[] imagePaths

An array of the image paths, for multiple texture pages.

lineHeightback to summary
public float lineHeight

The distance from one line of text to the next. To set this value, use setLineHeight(float).

markupEnabledback to summary
public boolean markupEnabled
missingGlyphback to summary
public BitmapFont.Glyph missingGlyph

The glyph to display for characters not in the font. May be null.

nameback to summary
public String name

The name of the font, or null.

padBottomback to summary
public float padBottom
padLeftback to summary
public float padLeft
padRightback to summary
public float padRight
padTopback to summary
public float padTop
scaleXback to summary
public float scaleX
scaleYback to summary
public float scaleY
spaceXadvanceback to summary
public float spaceXadvance

The width of the space character.

xCharsback to summary
public char[] xChars
xHeightback to summary
public float xHeight

The x-height, which is the distance from the top of most lowercase characters to the baseline.

Constructor Detail

BitmapFontDataback to summary
public BitmapFontData()

Creates an empty BitmapFontData for configuration before calling load(FileHandle, boolean), to subclass, or to populate yourself, e.g. using stb-truetype or FreeType.

BitmapFontDataback to summary
public BitmapFontData(FileHandle fontFile, boolean flip)

Method Detail

getFirstGlyphback to summary
public BitmapFont.Glyph getFirstGlyph()
getFontFileback to summary
public FileHandle getFontFile()
getGlyphback to summary
public BitmapFont.Glyph getGlyph(char ch)

Returns the glyph for the specified character, or null if no such glyph exists. Note that getGlyphs(GlyphRun, CharSequence, int, int, Glyph) should be be used to shape a string of characters into a list of glyphs.

getGlyphsback to summary
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:CharSequence

Characters to convert to glyphs. Will not contain newline or color tags. May contain "[[" for an escaped left square bracket.

lastGlyph:BitmapFont.Glyph

The glyph immediately before this run, or null if this is run is the first on a line of text. Used tp apply kerning between the specified glyph and the first glyph in this run.

getImagePathback to summary
public String getImagePath(int index)

Returns the image path for the texture page at the given index (the "id" in the BMFont file).

getImagePathsback to summary
public String[] getImagePaths()
getWrapIndexback to summary
public int getWrapIndex(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.

hasGlyphback to summary
public boolean hasGlyph(char ch)

Returns true if the font has the glyph, or if the font has a missingGlyph.

isBreakCharback to summary
public boolean isBreakChar(char c)
isWhitespaceback to summary
public boolean isWhitespace(char c)
loadback to summary
public void load(FileHandle fontFile, boolean flip)
scaleback to summary
public void scale(float amount)

Sets the font's scale relative to the current scale.

Exceptions
IllegalArgumentException:
if the resulting scale is zero.
See Also
setScale(float, float)
setGlyphback to summary
public void setGlyph(int ch, BitmapFont.Glyph glyph)
setGlyphRegionback to summary
public void setGlyphRegion(BitmapFont.Glyph glyph, TextureRegion region)
setLineHeightback to summary
public void setLineHeight(float height)

Sets the line height, which is the distance from one line of text to the next.

setScaleback to summary
public void setScale(float scaleX, float scaleY)

Scales the font by the specified amounts on both axes

Note that smoother scaling can be achieved if the texture backing the BitmapFont is using TextureFilter#Linear. The default is Nearest, so use a BitmapFont constructor that takes a TextureRegion.

Exceptions
IllegalArgumentException:
if scaleX or scaleY is zero.
setScaleback to summary
public void setScale(float scaleXY)

Scales the font by the specified amount in both directions.

Exceptions
IllegalArgumentException:
if scaleX or scaleY is zero.
See Also
setScale(float, float)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

com.badlogic.gdx.graphics.g2d back to summary

public Class BitmapFont.Glyph

extends Object
Class Inheritance

Represents a single character in a font page.

Field Summary

Modifier and TypeField and Description
public boolean
public int
public int
public byte[][]
public int
page

The index to the texture page that holds this glyph.

public int
public int
public float
u

public float
public float
v

public float
public int
public int
public int
public int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
getKerning(char ch)

public void
setKerning(int ch, int value)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

fixedWidthback to summary
public boolean fixedWidth
heightback to summary
public int height
idback to summary
public int id
kerningback to summary
public byte[][] kerning
pageback to summary
public int page

The index to the texture page that holds this glyph.

srcXback to summary
public int srcX
srcYback to summary
public int srcY
uback to summary
public float u
u2back to summary
public float u2
vback to summary
public float v
v2back to summary
public float v2
widthback to summary
public int width
xadvanceback to summary
public int xadvance
xoffsetback to summary
public int xoffset
yoffsetback to summary
public int yoffset

Constructor Detail

Glyphback to summary
public Glyph()

Method Detail

getKerningback to summary
public int getKerning(char ch)
setKerningback to summary
public void setKerning(int ch, int value)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.