Class BitmapFont.BitmapFontData

  • Enclosing class:
    BitmapFont

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

      • name

        public java.lang.String name
        The name of the font, or null.
      • imagePaths

        public java.lang.String[] imagePaths
        An array of the image paths, for multiple texture pages.
      • 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 hypen (-).
      • xChars

        public char[] xChars
      • capChars

        public char[] capChars
    • Constructor Detail

      • 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​(FileHandle fontFile,
                              boolean flip)
    • Method Detail

      • load

        public void load​(FileHandle fontFile,
                         boolean flip)
      • setLineHeight

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

        public boolean hasGlyph​(char ch)
        Returns true if the font has the glyph, or if the font has a missingGlyph.
      • 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. Used tp apply kerning between the specified glyph and the first glyph in this run.
      • getWrapIndex

        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.
      • 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()
      • 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)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object