Class

Font

Font(filename)

Constructor

# new Font(filename)

Load a '.FNT' file for GRX.

Please note that text rendering uses UTF8, but not all fonts provide all code points.

Parameters:
Name Type Description
filename *

name of the font file.

See:
  • SetMissingCharacter()

Members

string

# filename

Name of the FNT file.

number

# height

Font height

Array.<Array.<number>>

# ranges

Font character ranges. An array of ranges (two entry arrays with start/end codepoints)

Methods

# DrawStringCenter(x, y, text, foreground, background)

Draw a center aligned string to the canvas.

Parameters:
Name Type Description
x number

x position

y number

y position.

text string

the string to draw.

foreground Color

foreground color.

background Color

background color.

# DrawStringLeft(x, y, text, foreground, background)

Draw a left aligned string to the canvas.

Parameters:
Name Type Description
x number

x position

y number

y position.

text string

the string to draw.

foreground Color

foreground color.

background Color

background color.

# DrawStringRight(x, y, text, foreground, background)

Draw a right aligned string to the canvas.

Parameters:
Name Type Description
x number

x position

y number

y position.

text string

the string to draw.

foreground Color

foreground color.

background Color

background color.

# StringHeight(text) → {number}

Calculate string height for this font.

Parameters:
Name Type Description
text string

the string to check.

the height in pixels.

number

# StringWidth(text) → {number}

Calculate string width for this font.

Parameters:
Name Type Description
text string

the string to check.

the width in pixels.

number