Class BitmapFont.BitmapFontData

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

public static class BitmapFont.BitmapFontData
extends java.lang.Object
Backing data for a BitmapFont.
  • Field Summary

    Fields
    Modifier and Type Field Description
    float ascent
    The distance from the cap height to the top of the tallest glyph.
    float blankLineScale
    Multiplier for the line height of blank lines.
    char[] breakChars
    Additional characters besides whitespace where text is wrapped.
    char[] capChars  
    float capHeight
    The distance from the top of most uppercase characters to the baseline.
    float cursorX
    The amount to add to the glyph X position when drawing a cursor between glyphs.
    float descent
    The distance from the bottom of the glyph that extends the lowest to the baseline.
    float down
    The distance to move down when \n is encountered.
    boolean flipped  
    com.badlogic.gdx.files.FileHandle fontFile  
    BitmapFont.Glyph[][] glyphs  
    java.lang.String[] imagePaths
    An array of the image paths, for multiple texture pages.
    float lineHeight
    The distance from one line of text to the next.
    boolean markupEnabled  
    BitmapFont.Glyph missingGlyph
    The glyph to display for characters not in the font.
    float padBottom  
    float padLeft  
    float padRight  
    float padTop  
    float scaleX  
    float scaleY  
    float spaceXadvance
    The width of the space character.
    char[] xChars  
    float xHeight
    The x-height, which is the distance from the top of most lowercase characters to the baseline.
  • Constructor Summary

    Constructors
    Constructor Description
    BitmapFontData()
    Creates an empty BitmapFontData for configuration before calling load(FileHandle, boolean), to subclass, or to populate yourself, e.g.
    BitmapFontData​(com.badlogic.gdx.files.FileHandle fontFile, boolean flip)  
  • Method Summary

    Modifier and Type Method Description
    BitmapFont.Glyph getFirstGlyph()  
    com.badlogic.gdx.files.FileHandle getFontFile()  
    BitmapFont.Glyph getGlyph​(char ch)
    Returns the glyph for the specified character, or null if no such glyph exists.
    void getGlyphs​(GlyphLayout.GlyphRun run, java.lang.CharSequence str, int start, int end, BitmapFont.Glyph lastGlyph)
    Using the specified string, populates the glyphs and positions of the specified glyph run.
    java.lang.String getImagePath​(int index)
    Returns the image path for the texture page at the given index (the "id" in the BMFont file).
    java.lang.String[] getImagePaths()  
    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 a missingGlyph.
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • imagePaths

      public java.lang.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.
    • glyphs

      public final BitmapFont.Glyph[][] glyphs
    • 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 hypen (-).
    • 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, java.lang.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 java.lang.String getImagePath​(int index)
      Returns the image path for the texture page at the given index (the "id" in the BMFont file).
    • getImagePaths

      public java.lang.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:
      java.lang.IllegalArgumentException - if scaleX or scaleY is zero.
    • setScale

      public void setScale​(float scaleXY)
      Scales the font by the specified amount in both directions.
      Throws:
      java.lang.IllegalArgumentException - if scaleX or scaleY is zero.
      See Also:
      setScale(float, float)
    • scale

      public void scale​(float amount)
      Sets the font's scale relative to the current scale.
      Throws:
      java.lang.IllegalArgumentException - if the resulting scale is zero.
      See Also:
      setScale(float, float)