Class LazyFont.LazyChar

Object
LazyChar
Enclosing class:
LazyFont

public class LazyFont.LazyChar extends Object
Keeps track of the metadata for each supported character in a font. This is used internally to wrap and render text, and it is unlikely that end users will ever need to use this class or any of its methods in their code.

In the rare case that these methods are needed, their names should match the bitmap font file format found here under the char and kerning headings. The exact details differ for reasons based on implementing them into OpenGL - check the Javadoc for any differences from the specification.

Since:
2.3
Author:
LazyWizard
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the total amount of horizontal space this character takes up at base font size.
    int
    Returns the height of the character in the underlying texture atlas.
    int
    Returns the Unicode character code matching this character.
    int
    getKerning(char otherChar)
    Returns the amount of kerning (extra padding) to add before drawing this character immmediately after the other.
    int
    getKerning(int otherCharId)
    Returns the amount of kerning (extra padding) to add before drawing this character immmediately after the other.
    Returns a map containing the amount of kerning (extra padding) to add before drawing this character immmediately after various others.
    float
    The leftmost position of the character in the underlying texture, as a ratio of its total width.
    float
    The rightmost position of the character in the underlying texture, as a ratio of its total width.
    float
    The topmost position of the character in the underlying texture, as a ratio of its total width.
    float
    The bottom-most position of the character in the underlying texture, as a ratio of its total width.
    int
    Returns the width of the character in the underlying texture atlas.
    int
    Returns how much extra empty space to add to the left of this character before drawing it.
    int
    Returns how much extra empty space to add to the top of this character before drawing it.
    void
    setKerning(char otherChar, int kerning)
    Sets the amount of kerning (extra padding) to add before drawing this character immmediately after the other.
    void
    setKerning(int otherCharId, int kerning)
    Sets the amount of kerning (extra padding) to add before drawing this character immmediately after the other.

    Methods inherited from class Object

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

    • getKernings

      public Map<Integer,Integer> getKernings()
      Returns a map containing the amount of kerning (extra padding) to add before drawing this character immmediately after various others. Kerning makes fonts look better.
      Returns:
      A map containing the number of extra pixels to add at base font size before drawing this character immediately after various others. The key is the Unicode ID of the other character, and the value is the number of pixels to add when drawing this LazyFont.LazyChar after it.
      Since:
      2.3
    • getTx1

      public float getTx1()
      The leftmost position of the character in the underlying texture, as a ratio of its total width.
      Returns:
      The leftmost position of the character in the underlying texture, as a ratio of its total width (for example, a character whose texture starts exactly 1/5th along the x axis of the texture atlas would have a tx1 of 0.2).
      Since:
      2.3
    • getTx2

      public float getTx2()
      The rightmost position of the character in the underlying texture, as a ratio of its total width.
      Returns:
      The rightmost position of the character in the underlying texture, as a ratio of its total width (for example, a character whose texture ends exactly 1/5th along the x axis of the texture atlas would have a tx2 of 0.2).
      Since:
      2.3
    • getTy1

      public float getTy1()
      The topmost position of the character in the underlying texture, as a ratio of its total width.
      Returns:
      The topmost position of the character in the underlying texture, as a ratio of its total width (for example, a character whose texture starts exactly 1/5th along the y axis of the texture atlas would have a ty1 of 0.2).
      Since:
      2.3
    • getTy2

      public float getTy2()
      The bottom-most position of the character in the underlying texture, as a ratio of its total width.
      Returns:
      The bottom-most position of the character in the underlying texture, as a ratio of its total width (for example, a character whose texture ends exactly 1/5th along the y axis of the texture atlas would have a ty2 of 0.2).
      Since:
      2.3
    • setKerning

      public void setKerning(int otherCharId, int kerning)
      Sets the amount of kerning (extra padding) to add before drawing this character immmediately after the other. Kerning makes fonts look better.
      Parameters:
      otherCharId - The Unicode ID of the character to add kerning data for. When drawing a LazyFont.DrawableString, this character will have extra padding when drawn after the LazyFont.LazyChar with the id otherCharId.
      kerning - The number of extra pixels to add at base font size before drawing this character immediately after the LazyFont.LazyChar with ID otherCharId.
      Since:
      2.3
    • getKerning

      public int getKerning(int otherCharId)
      Returns the amount of kerning (extra padding) to add before drawing this character immmediately after the other. Kerning makes fonts look better.
      Parameters:
      otherCharId - The Unicode ID of the character to add kerning data for. When drawing a LazyFont.DrawableString, this character will have extra padding when drawn after the LazyFont.LazyChar with the id otherCharId.
      Returns:
      The number of extra pixels to add at base font size before drawing this character immediately after the LazyFont.LazyChar with ID otherCharId.
      Since:
      2.3
    • setKerning

      public void setKerning(char otherChar, int kerning)
      Sets the amount of kerning (extra padding) to add before drawing this character immmediately after the other. Kerning makes fonts look better.
      Parameters:
      otherChar - The character to add kerning data for. When drawing a LazyFont.DrawableString, this character will have extra padding when drawn after otherChar.
      kerning - The number of extra pixels to add at base font size before drawing this character immediately after otherChar.
      Since:
      2.3
    • getKerning

      public int getKerning(char otherChar)
      Returns the amount of kerning (extra padding) to add before drawing this character immmediately after the other. Kerning makes fonts look better.
      Parameters:
      otherChar - The character to add kerning data for. When drawing a LazyFont.DrawableString, this character will have extra padding when drawn after otherCharId.
      Returns:
      The number of extra pixels to add at base font size before drawing this character immediately after otherChar.
      Since:
      2.3
    • getId

      public int getId()
      Returns the Unicode character code matching this character.
      Returns:
      The character code of the underlying Character in Unicode.
      Since:
      2.3
    • getWidth

      public int getWidth()
      Returns the width of the character in the underlying texture atlas.
      Returns:
      The width of the character in the texture atlas, in pixels.
      Since:
      2.3
    • getHeight

      public int getHeight()
      Returns the height of the character in the underlying texture atlas.
      Returns:
      The height of the character in the texture atlas, in pixels.
      Since:
      2.3
    • getXOffset

      public int getXOffset()
      Returns how much extra empty space to add to the left of this character before drawing it. Used for alignment.
      Returns:
      The amount of space to move right horizontally before drawing, in pixels, at the base font size. Used for alignment.
      Since:
      2.3
    • getYOffset

      public int getYOffset()
      Returns how much extra empty space to add to the top of this character before drawing it. Used for alignment.
      Returns:
      The amount of space to move down vertically before drawing, in pixels, at the base font size. Used for alignment.
      Since:
      2.3
    • getAdvance

      public int getAdvance()
      Returns the total amount of horizontal space this character takes up at base font size.
      Returns:
      The number of pixels this character takes up horizontally at base font size, minus any kerning.
      Since:
      2.3