Package rosequartz.gfx
Class BitmapFont
java.lang.Object
rosequartz.gfx.BitmapFont
- All Implemented Interfaces:
Font<BitmapFont>
Represents a bitmap-font made from a texture.
-
Constructor Summary
ConstructorsConstructorDescriptionBitmapFont(Texture texture)Creates a bitmap-font from a texture containing all glyphs. -
Method Summary
Modifier and TypeMethodDescriptionfloatgetTextHeight(String text, float height, float spacingVertical)Gets the height of a given text.floatgetTextWidth(String text, float height, float spacingHorizontal)Gets the width of a given text.glyph(char glyph, int glyphX, int glyphY, int glyphWidth, int glyphHeight)Defines the source position of a glpyh.render(String text, float x, float y, float height, float spacingHorizontal, float spacingVertical)Render a given text onto the current target frame buffer using texture coordinates.
-
Constructor Details
-
BitmapFont
Creates a bitmap-font from a texture containing all glyphs.- Parameters:
texture- glyph-texture- Throws:
NotOnGraphicsThreadException
-
-
Method Details
-
glyph
Defines the source position of a glpyh.- Parameters:
glyph- glyph to defineglyphX- position of the top left corner of the glyph on the source texture on the x-axis in pixelsglyphY- position of the top left corner of the glyph on the source texture on the y-axis in pixelsglyphWidth- width of the glyph on the source texture in pixelsglyphHeight- height of the glyph on the source texture in pixels- Returns:
- this
-
getTextWidth
Description copied from interface:FontGets the width of a given text.- Specified by:
getTextWidthin interfaceFont<BitmapFont>- Parameters:
text- text to calculate width ofheight- height of the textspacingHorizontal- spacing between characters on the x-axis
-
getTextHeight
Description copied from interface:FontGets the height of a given text.- Specified by:
getTextHeightin interfaceFont<BitmapFont>- Parameters:
text- text to calculate width ofheight- height of the textspacingVertical- spacing between characters on the y-axis
-
render
public BitmapFont render(String text, float x, float y, float height, float spacingHorizontal, float spacingVertical) throws NotOnGraphicsThreadExceptionDescription copied from interface:FontRender a given text onto the current target frame buffer using texture coordinates.- Specified by:
renderin interfaceFont<BitmapFont>- Parameters:
text- text to renderx- position of the bottom left corner of the rendered text on the x-axisy- position of the bottom left corner of the rendered text on the y-axisheight- height of the textspacingHorizontal- space between every character on the x-axisspacingVertical- space between every character on the y-axis- Throws:
NotOnGraphicsThreadException
-