dxCreateFont | Multi Theft Auto: Wiki Skip to content

dxCreateFont

Client-side
Server-side
Shared

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


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.

OOP Syntax Help! I don't understand this!

Syntax

element 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

  • element: value

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

Code Examples

shared
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)