object.font

Type Userdata
Object TextField
Library native.*
Revision Release 2024.3703
Keywords native text input
See also object:resizeFontToFitHeight()
object:resizeHeightToFitFont()

Overview

Gets or sets the native text field's font. May be set to a font object as returned by the native.newFont() function.

Gotchas

The font size read or written to this property may be either in Corona's content-scaled points or the platform's native points. You can determine which font size units are currently being used by querying the text field's object.isFontSizeScaled property.

By default, the font size is measured in Corona's content-scaled point system, just like display.newText(), but the default can be changed via the "isNativeTextFieldFontSizeScaled" key of display.setDefault().

Example

local myField = native.newTextField( 10, 30, 180, 30 )
myField.font = native.newFont( native.systemFontBold, 18 )
myField:resizeHeightToFitFont()