Text

open class Text : UIResourceElement

A text ui element to display text on the glasses screen

Each font is defined by a font slot Text length (in bytes!) is limited to the communication channel mtu-10 bytes

2 types of fonts can be used:

  • Stock fonts that comes pre-installed with the glasses

  • Custom font slots that can be created, added to the application resources and uploaded to the glasses

Custom fonts creation is in beta and documented separately Max size 32KB All custom slots are persistent, meaning uploaded fonts for those slots are kept saved on the glasses between reboots

NOTE: The behaviour of adding 2 (or more) different custom fonts with the same slot to the same screen is undefined

Supported transformations: Translate

See also

Inheritors

Constructors

Link copied to clipboard
constructor()
constructor(id: String)
constructor(font: Font)

Constructor, defining a font for the Text

constructor(id: String, font: Font)

Constructor, defining a font and id for the Text

Functions

Link copied to clipboard
protected open override fun drawBackground(canvas: CanvasBuffer)

Draws the ui element background

Link copied to clipboard
protected open override fun drawBorder(canvas: CanvasBuffer, color: Int, widthPix: Int, cornerRadiusPix: Float)

Override this function to enable custom border drawing when showBorder is true

Link copied to clipboard
open override fun getHeight(): Float

Receive the ui element height

Link copied to clipboard

Return the measured height of the text (getText in pixels

Link copied to clipboard

Return the measured width of the text (getText in pixels

Link copied to clipboard

Get the Font

Link copied to clipboard
open fun getText(): String

Get the ui element text

Link copied to clipboard

Get the text align

Link copied to clipboard
open override fun getUIResource(): Font

Returns the resource of the UI element if exists

Link copied to clipboard
open override fun getWidth(): Float

Receive the ui element width

Link copied to clipboard
open override fun getXEnd(): Float

The getXEnd returned value is dependent on the getTextAlign as follows:

Link copied to clipboard
open override fun isDirty(): Boolean

Return true if the ui element was changed from the last draw

Link copied to clipboard
protected open override fun onDraw(canvas: CanvasBuffer)

The draw method is called to actually draw the ui element visual representation to the CanvasBuffer

Link copied to clipboard
open override fun rotate(angleDegrees: Float): UIElement
open override fun rotate(angleDegrees: Float, px: Float, py: Float, pivot: Pivot): UIElement

not supported for text

Link copied to clipboard
open override fun scale(sx: Float, sy: Float): UIElement
open override fun scale(sx: Float, sy: Float, px: Float, py: Float, pivot: Pivot): UIElement

not supported for text

Link copied to clipboard

Set the text Align to be center, and define the x position of the text

Link copied to clipboard
open override fun setDimensions(x: Float, y: Float, width: Float, height: Float): UIElement

Sets the ui element dimensions

Link copied to clipboard
open fun setEllipsis(ellipsis: Boolean): Text

Enable\Disable ellipsis. Works if the Text width is defined

Link copied to clipboard
open fun setResource(font: Font): Text

Set the font information

Set stock font type

Link copied to clipboard
open fun setText(text: String): Text

Set the text to be displayed

Link copied to clipboard
fun setTextAlign(align: Align): Text

Set the text align

Link copied to clipboard
open override fun setWidth(width: Float): UIElement

Sets the ui element width

Link copied to clipboard
open override fun setWidthHeight(width: Float, height: Float): UIElement

Sets the ui element size

Link copied to clipboard
open override fun toString(): String

To String