FontCache

open class FontCache(val pages: Int = 1)

Caches glyph geometry to provide a fast way to render static textures without having recompute the glyph each time. This is a base class and can be extended to add additional functionality to specific fonts.

Author

Colton Daily

See also

Constructors

Link copied to clipboard
fun FontCache(pages: Int = 1)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun addText(font: Font, text: CharSequence, x: Float, y: Float, scaleX: Float = 1.0f, scaleY: Float = 1.0f, rotation: Angle = Angle.ZERO, color: Color = Color.WHITE, targetWidth: Float = 0.0f, align: HAlign = HAlign.LEFT, wrap: Boolean = false, truncate: String? = null)

Adds new glyphs of the specified string of text on top of any existing glyphs.

Link copied to clipboard
fun clear()

Clears any existing glyphs from the cache.

Link copied to clipboard
fun draw(batch: Batch, textures: List<Texture>)

Draws the text using the specified batch and list of textures. The textures list size must be >= pages

Link copied to clipboard
fun setPosition(px: Float, py: Float)

Sets the position of the text.

Link copied to clipboard
fun setText(layout: GlyphLayout, x: Float, y: Float, scaleX: Float = 1.0f, scaleY: Float = 1.0f, rotation: Angle = Angle.ZERO, color: Color = Color.WHITE)

Clears any existing glyphs of previous text and uses layout to compile the glyphs to cache.

fun setText(font: Font, text: CharSequence, x: Float, y: Float, scaleX: Float = 1.0f, scaleY: Float = 1.0f, rotation: Angle = Angle.ZERO, color: Color = Color.WHITE, targetWidth: Float = 0.0f, align: HAlign = HAlign.LEFT, wrap: Boolean = false, truncate: String? = null)

Clears any existing glyphs of previous text and adds the new glyphs of the specified string of text.

Link copied to clipboard
fun tint(tint: Color)

Tints the existing text in the cache.

Link copied to clipboard
fun translate(tx: Float, ty: Float)

Moves the position of the text by the specified amount.

Properties

Link copied to clipboard
val pages: Int = 1

Inheritors

Link copied to clipboard