Class Font.FontData

Direct Known Subclasses:
Enclosing class:

public static class Font.FontData extends Object
Backing data for a Font.
  • Field Details

    • glyphs

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

      public String[] imagePaths
      An array of the image paths, for multiple texture pages.
    • fontFile

      public Fi 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 Font.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

    • FontData

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

      public FontData(Fi fontFile, boolean flip)
  • Method Details

    • load

      public void load(Fi fontFile, boolean flip)
    • setGlyphRegion

      public void setGlyphRegion(Font.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, Font.Glyph glyph)
    • getFirstGlyph

      public Font.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 Font.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, Font.Glyph lastGlyph)
      Using the specified string, populates the glyphs and positions of the specified glyph run.
      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(Seq<Font.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 Fi 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.

      IllegalArgumentException - if scaleX or scaleY is zero.
    • setScale

      public void setScale(float scaleXY)
      Scales the font by the specified amount in both directions.
      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.
      IllegalArgumentException - if the resulting scale is zero.
      See Also: