Overview
The TextRenderer class extends Renderer
and is used to draw text onto the canvas.
It supports custom fonts, alignment, color, and text styling.
Field Summary
float fontSize
– Font size in pixels (default:30
).String text
– Text content to render.int textcolor
– Color of the text (default:Color.WHITE
).boolean centered
– Whether the text should be horizontally centered.boolean isBold
– Whether the text should be bold.Typeface typeface
– Typeface to use for rendering.FontFrom fontfrom
– Enum specifying font source:Asset
,File
,Default
, orResource
.String fontpath
– Path to font if loaded from file or assets.int fontResourceId
– Resource ID for font loading via Android Resources.
Enum: FontFrom
Asset
– Load font from assets folder.File
– Load font from external/internal file path.Default
– Use system default font.Resource
– Load font using Android resource ID.
Method Summary
void render(Canvas canvas, GameObject object, Paint p, GameView gv)
Draws the text to the canvas based on alignment, font, size, and styling.
FontFrom getFontFrom()
/ void setFontFrom(FontFrom fontfrom)
Gets or sets the source from which the font is loaded.
float getFontSize()
/ void setFontSize(float fontSize)
Gets or sets the font size in pixels.
String getText()
/ void setText(String text)
Gets or sets the text to render.
String getFontPath()
/ void setFontPath(String fontpath)
Gets or sets the path to the font file.
int getTextcolor()
/ void setTextcolor(int textcolor)
Gets or sets the text color.
int getFontResourceId()
/ void setFontResourceId(int fontResourceId)
Gets or sets the font resource ID for loading fonts from Android resources.
boolean isCentered()
/ void setCentered(boolean centered)
Checks or sets whether the text is horizontally centered.
boolean isBold()
/ void setBold(boolean isBold)
Checks or sets whether the text should be bold.