Class BitmapFont.BitmapFontData

java.lang.Object
gaiasky.util.gdx.g2d.BitmapFont.BitmapFontData
Enclosing class:
BitmapFont

public static class BitmapFont.BitmapFontData extends Object
Backing data for a BitmapFont.
  • Field Details

    • glyphs

      public final BitmapFont.Glyph[][] glyphs
    • imagePaths

      public String[] 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 lineHeight
      The distance from one line of text to the next. To set this value, use setLineHeight(float).
    • capHeight

      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.
    • ascent

      public float ascent
      The distance from the cap height to the top of the tallest glyph.
    • descent

      public float descent
      The distance from the bottom of the glyph that extends the lowest to the baseline. This number is negative.
    • down

      public float down
      The distance to move down when \n is encountered.
    • blankLineScale

      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.
    • scaleX

      public float scaleX
    • scaleY

      public float scaleY
    • markupEnabled

      public boolean markupEnabled
    • cursorX

      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.
    • missingGlyph

      public BitmapFont.Glyph missingGlyph
      The glyph to display for characters not in the font. May be null.
    • spaceXadvance

      public float spaceXadvance
      The width of the space character.
    • xHeight

      public float xHeight
      The x-height, which is the distance from the top of most lowercase characters to the baseline.
    • breakChars

      public char[] breakChars
      Additional 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 calling load(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

      public void setGlyphRegion(BitmapFont.Glyph glyph, TextureRegion region)
    • setLineHeight

      public void setLineHeight(float height)
      Sets the line height, which is the distance from one line of text to the next.
    • setGlyph

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

      public BitmapFont.Glyph getFirstGlyph()
    • hasGlyph

      public boolean hasGlyph(char ch)
      Returns true if the font has the glyph, or if the font has a missingGlyph.
    • getGlyph

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

      public 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.
    • isBreakChar

      public boolean isBreakChar(char c)
    • isWhitespace

      public boolean isWhitespace(char c)
    • getImagePath

      public String getImagePath(int index)
      Returns the image path for the texture page at the given index (the "id" in the BMFont file).
    • getImagePaths

      public String[] 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 axes

      Note 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 a TextureRegion.

      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: