Class Font
java.lang.Object
dev.prozilla.pine.common.asset.text.Font
- All Implemented Interfaces:
Asset,Destructible
Contains a font texture for drawing text.
Font textures are created using stb_truetype
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final Colorstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionFont(int size) Font(InputStream in, int size) Creates a font from a TTF input stream.Font(InputStream in, int size, boolean antiAlias) Creates a font from a TTF input stream. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Deletes the font.voiddrawText(Renderer renderer, CharSequence text, float x, float y, float z) Draws text on the screen at the given coordinates with the default text color using this font.voiddrawText(Renderer renderer, CharSequence text, float x, float y, float z, Color c) Draws text on the screen at the given coordinates using this font.static StringgenerateKey(String path, int size) floatgetHeight(CharSequence text) Calculates the height of a character sequence in this font.getPath()Returns the path to the file this asset was loaded from.intgetSize()floatgetWidth(CharSequence text) Calculates the width of a character sequence in this font.setSize(int size) Creates a new font from the same font file, but with a different size.
-
Field Details
-
path
-
DEFAULT_SIZE
public static final int DEFAULT_SIZE- See Also:
-
DEFAULT_COLOR
-
FIRST_CHAR
public static final int FIRST_CHAR- See Also:
-
CHAR_COUNT
public static final int CHAR_COUNT- See Also:
-
DEL_CHAR
public static final int DEL_CHAR- See Also:
-
-
Constructor Details
-
Font
Creates a font from a TTF input stream.- Throws:
IOException
-
Font
Creates a font from a TTF input stream.- Throws:
IOException
-
Font
public Font(int size)
-
-
Method Details
-
getWidth
Calculates the width of a character sequence in this font.- Parameters:
text- The character sequence- Returns:
- The width of the character sequence.
-
getHeight
Calculates the height of a character sequence in this font.- Parameters:
text- The character sequence- Returns:
- The height of the character sequence.
-
getSize
public int getSize() -
drawText
Draws text on the screen at the given coordinates with the default text color using this font.- Parameters:
renderer- The renderer to usetext- The text to drawx- The x positiony- The y positionz- The z position
-
drawText
Draws text on the screen at the given coordinates using this font.- Parameters:
renderer- The renderer to usetext- The text to drawx- The x positiony- The y positionz- The z positionc- The color to draw the text in
-
setSize
Creates a new font from the same font file, but with a different size. -
getPath
Description copied from interface:AssetReturns the path to the file this asset was loaded from. -
destroy
public void destroy()Deletes the font.- Specified by:
destroyin interfaceAsset- Specified by:
destroyin interfaceDestructible
-
generateKey
-