Class Font
java.lang.Object
dev.prozilla.pine.common.system.resource.text.Font
- All Implemented Interfaces:
Lifecycle
Contains a font texture for drawing text.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFont()
Creates a default anti-aliased font with monospaced glyphs and default size 16.Font
(boolean antiAlias) Creates a default font with monospaced glyphs and default size 16.Font
(int size) Creates a default anti-aliased font with monospaced glyphs and specified size.Font
(int size, boolean antiAlias) Creates a default font with monospaced glyphs and specified size.Creates an anti-aliased font from an AWT Font.Creates a font from an AWT Font.Font
(InputStream in, int size) Creates an anti-aliased Font from an input stream.Font
(InputStream in, int size, boolean antiAlias) Creates a Font from an input stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Deletes the font.void
drawText
(Renderer renderer, CharSequence text, float x, float y, float z) Draw text at the specified position.void
drawText
(Renderer renderer, CharSequence text, float x, float y, float z, Color c) Draw text at the specified position and color.static String
generateKey
(String path, int size) int
getHeight
(CharSequence text) Gets the height of the specified text.int
getWidth
(CharSequence text) Gets the width of the specified text.setSize
(int size) Creates a new font from the same font file, but with a different size.
-
Field Details
-
path
-
COLOR_DEFAULT
-
-
Constructor Details
-
Font
public Font()Creates a default anti-aliased font with monospaced glyphs and default size 16. -
Font
public Font(boolean antiAlias) Creates a default font with monospaced glyphs and default size 16.- Parameters:
antiAlias
- Whether the font should be anti-aliased or not
-
Font
public Font(int size) Creates a default anti-aliased font with monospaced glyphs and specified size.- Parameters:
size
- Font size
-
Font
public Font(int size, boolean antiAlias) Creates a default font with monospaced glyphs and specified size.- Parameters:
size
- Font sizeantiAlias
- Whether the font should be anti-aliased or not
-
Font
Creates an anti-aliased Font from an input stream.- Parameters:
in
- The input streamsize
- Font size- Throws:
FontFormatException
- if fontFile does not contain the required font tables for the specified formatIOException
- If font can't be read
-
Font
Creates a Font from an input stream.- Parameters:
in
- The input streamsize
- Font sizeantiAlias
- Whether the font should be anti-aliased or not- Throws:
FontFormatException
- if fontFile does not contain the required font tables for the specified formatIOException
- If font can't be read
-
Font
Creates an anti-aliased font from an AWT Font.- Parameters:
font
- The AWT Font
-
Font
Creates a font from an AWT Font.- Parameters:
font
- The AWT FontantiAlias
- Whether the font should be anti-aliased or not
-
-
Method Details
-
getWidth
Gets the width of the specified text.- Parameters:
text
- The text- Returns:
- Width of text
-
getHeight
Gets the height of the specified text.- Parameters:
text
- The text- Returns:
- Height of text
-
drawText
Draw text at the specified position and color.- Parameters:
renderer
- The renderer to usetext
- TextRenderer to drawx
- X coordinate of the text positiony
- Y coordinate of the text positionc
- Color to use
-
drawText
Draw text at the specified position.- Parameters:
renderer
- The renderer to usetext
- TextRenderer to drawx
- X coordinate of the text positiony
- Y coordinate of the text position
-
setSize
Creates a new font from the same font file, but with a different size. -
destroy
public void destroy()Deletes the font. -
generateKey
-