public interface SpriteFont extends Sprite
SpriteFont is an extended sprite that allows to handle a font based on an image. This way is it possible to create a custom font, were data (contained in an XML file) describes each letter size.
It is based on a SpriteTiled
, which allow to control each letter separately. There is then a correspondence
between each character and their image. It also supports a full text rendering, where the special character
NEW_LINE
can be used to insert a new line during rendering.
The usage is simple:
draw(Graphic, int, int, Align, String)
can be used to render a single text (which can contains
NEW_LINE
characters).draw(Graphic, int, int, Align, String...)
can be used to render many texts, where each of them is
separated by a new line automatically.As the SpriteFont is a sprite, is supports all sprite operations.
Modifier and Type | Field and Description |
---|---|
static char |
NEW_LINE
New line char.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(Graphic g,
int x,
int y,
Align align,
String... text)
Draw a multiple text at specified location.
|
void |
draw(Graphic g,
int x,
int y,
Align align,
String text)
Draw a single text at specified location.
|
int |
getTextHeight(String text)
Get global text height.
|
int |
getTextWidth(String text)
Get global text width.
|
void |
setAlign(Align align)
Set text alignment.
|
void |
setLineHeight(int height)
Set line height (default = letter height).
|
void |
setText(String text)
Set text to render.
|
filter, getMirror, rotate, setAlpha, setFade, setMirror, setTransparency, stretch
getSurface, load, prepare, setLocation, setLocation, setOrigin
getX, getY
render
static final char NEW_LINE
void draw(Graphic g, int x, int y, Align align, String text)
NEW_LINE
.g
- The graphics output.x
- The location x.y
- The location y.align
- The alignment.text
- The input text.void draw(Graphic g, int x, int y, Align align, String... text)
g
- The graphics output.x
- The location x.y
- The location y.align
- The alignment.text
- The input text.void setText(String text)
text
- The text to render.void setAlign(Align align)
align
- The text alignment.void setLineHeight(int height)
height
- The line height.int getTextWidth(String text)
text
- The input text.int getTextHeight(String text)
text
- The input height.Copyright © 2017 Byron 3D Games Studio. All rights reserved.