Font

interface Font

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val ascent: Float

The font ascent is the distance from the font's baseline to the top of most alphanumeric characters. NOTE. I've read that ascent is sometimes defined as the position of the top of the glyph relative to the baseline, and is therefore negative. ascent is always positive.

Link copied to clipboard
abstract val bottom: Float

The maximum descent of the Font. No character should extend further below the font's baseline than this. "Badly behaved" fonts do not adhere to this though. This field is taken from the font's meta-data, not from the shape of the glyph itself, and these can very well differ :-(

Link copied to clipboard
abstract val descent: Float

The font descent is the distance from the font's baseline to the bottom of most alphanumeric characters with descenders.

Link copied to clipboard
abstract val fixedWidth: Float

The width of all glyphs (if this is a fixed width font, otherwise 0.

Link copied to clipboard
abstract val height: Float

This is the distance between the baseline of adjacent lines of text. It is the sum of the leading + ascent + descent.

Link copied to clipboard
Link copied to clipboard

The inverse slope of the caret which best matches the posture of this Font.

Link copied to clipboard
Link copied to clipboard
abstract val maxWidthOfDigit: Float

The width of the widest digit as well as "." and "-" Suitable for working out prefWidths of TextFields which contain only numbers.

Link copied to clipboard
abstract val top: Float

The maximum ascent of the Font. No character should extend further above the font's baseline than this. "Badly behaved" fonts to not adhere to this though. This field is taken from the font's meta-data, not from the shape of the glyph itself, and these can very well differ :-(

Functions

Link copied to clipboard
open fun bold(): Font
Link copied to clipboard
open fun boldItalics(): Font
Link copied to clipboard
abstract fun caretPosition(text: CharSequence, x: Float, indentationColumns: Int): Int
Link copied to clipboard
open fun draw(text: CharSequence, color: Color, x: Float, y: Float, hAlignment: HAlignment = HAlignment.LEFT, vAlignment: TextVAlignment = TextVAlignment.BASELINE, indentationColumns: Int = 0, startColumn: Int = 0, modelMatrix: Matrix? = null)

Draw text at position x,y.

Link copied to clipboard
open fun drawMultiLine(text: CharSequence, color: Color, x: Float, y: Float, hAlignment: HAlignment, vAlignment: TextVAlignment, lineSpacingMultiplier: Float = 1.25f, indentationColumns: Int, modelMatrix: Matrix? = null)
open fun drawMultiLine(text: List<CharSequence>, color: Color, x: Float, y: Float, hAlignment: HAlignment, vAlignment: TextVAlignment, lineSpacingMultiplier: Float = 1.25f, lineSpacingExtra: Float = 0.0f, indentationColumns: Int, modelMatrix: Matrix? = null)
Link copied to clipboard
abstract fun drawTopLeft(text: CharSequence, color: Color, x: Float, y: Float, indentationColumns: Int, startColumn: Int = 0, modelMatrix: Matrix? = null)

Draws text where the top left of the first glyph is at x, y

Link copied to clipboard
abstract fun hasGlyph(c: Char): Boolean
Link copied to clipboard
open fun image(): Image?

For bitmap based fonts, returns the texture, otherwise null. I use this for debugging only, and probably has no other value.

Link copied to clipboard
open fun italics(): Font
Link copied to clipboard
open fun noBold(): Font
Link copied to clipboard
open fun noItalics(): Font
Link copied to clipboard
open fun plain(): Font
Link copied to clipboard
abstract fun widthOf(text: CharSequence, indentationColumns: Int, startColumn: Int = 0): Float

Calculates the width of text in pixels. indentationColumns and startColumn are required to correctly work out the width of a tab character.

Link copied to clipboard
open fun widthOfOrZero(text: CharSequence, indentationColumns: Int, startColumn: Int = 0): Float