native.newFont()

Type Function
Library native.*
Return value Userdata
Revision Release 2024.3703
Keywords font, custom font, fonts
See also Using Custom Fonts (guide)
native.getFontNames()
display.newText()

Overview

Creates a font object that you can use to specify fonts in native text fields, native text boxes, and text display objects.

Gotchas

Available fonts are platform-dependent. Also, the fonts available in the Simulator may be different from the fonts actually available on the device. When in doubt, check the available device font names using native.getFontNames().

Syntax

native.newFont( name [, size] )
name (required)

String, Userdata, or Constant. This can be one of the following:

size (optional)

Number. The point size of the font to use. By default, it will be the standard system font size of the device.

Example

local textBox = native.newTextBox( 30, 140, 260, 100 )
textBox.font = native.newFont( "Helvetica-Bold", 16 )
textBox:setTextColor( 0.5 )