dxCreateFont | Multi Theft Auto: Wiki Skip to content

dxCreateFont

Client-side
Server-side
Shared

This function creates a DX Font element that can be used in dxDrawText. Successful font creation is not guaranteed, and may fail due to hardware or memory limitations.

Note

The size can't be less than 5 or more than 150. Use this function after onClientResourceStart, otherwise some characters may be displayed incorrectly.

Tip
  • It is highly recommended that dxSetTestMode is used when writing and testing scripts using dxCreateFont.
  • You should always check to see if this function has returned false.

OOP Syntax Help! I don't understand this!

Syntax

dx-font|false dxCreateFont ( ​string filepath, [ ​int size = 9, ​bool bold = false, ​string quality = "proof" ] )
Required Arguments
  • filepath: The name of the file containing the font.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • size (default: 9): Size of the font.
  • bold (default: false): Flag to indicate if the font should be bold.
  • quality (default: "proof"): The font quality.
    • default: not the actual default.
    • draft
    • proof: the default.
    • nonantialiased
    • antialiased
    • cleartype
    • cleartype_natural

Returns

  • dx-font|false: font

Returns a DX font element if successful, false if invalid arguments were passed to the function, or there is insufficient resources available.

Code Examples

client
local font = dxCreateFont('myfont.ttf', 20, false, 'proof') or 'default' -- fallback to default
addEventHandler('onClientRender', root, function()
dxDrawText('Example Text', 100, 350, 300, 350, tocolor(255, 255, 0), 1, font)
end)