Package org.lazywizard.lazylib.ui
Class LazyFont.LazyChar
Object
LazyChar
- Enclosing class:
- LazyFont
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 TypeMethodDescriptionintReturns the total amount of horizontal space this character takes up at base font size.intReturns the height of the character in the underlying texture atlas.intgetId()Returns the Unicode character code matching this character.intgetKerning(char otherChar) Returns the amount of kerning (extra padding) to add before drawing this character immmediately after the other.intgetKerning(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.floatgetTx1()The leftmost position of the character in the underlying texture, as a ratio of its total width.floatgetTx2()The rightmost position of the character in the underlying texture, as a ratio of its total width.floatgetTy1()The topmost position of the character in the underlying texture, as a ratio of its total width.floatgetTy2()The bottom-most position of the character in the underlying texture, as a ratio of its total width.intgetWidth()Returns the width of the character in the underlying texture atlas.intReturns how much extra empty space to add to the left of this character before drawing it.intReturns how much extra empty space to add to the top of this character before drawing it.voidsetKerning(char otherChar, int kerning) Sets the amount of kerning (extra padding) to add before drawing this character immmediately after the other.voidsetKerning(int otherCharId, int kerning) Sets the amount of kerning (extra padding) to add before drawing this character immmediately after the other.
-
Method Details
-
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.LazyCharafter 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 aLazyFont.DrawableString, this character will have extra padding when drawn after theLazyFont.LazyCharwith the idotherCharId.kerning- The number of extra pixels to add at base font size before drawing this character immediately after theLazyFont.LazyCharwith IDotherCharId.- 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 aLazyFont.DrawableString, this character will have extra padding when drawn after theLazyFont.LazyCharwith the idotherCharId.- Returns:
- The number of extra pixels to add at base font size before drawing this character
immediately after the
LazyFont.LazyCharwith IDotherCharId. - 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 aLazyFont.DrawableString, this character will have extra padding when drawn afterotherChar.kerning- The number of extra pixels to add at base font size before drawing this character immediately afterotherChar.- 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 aLazyFont.DrawableString, this character will have extra padding when drawn afterotherCharId.- 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
Characterin 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
-