guiCreateFont | Multi Theft Auto: Wiki Skip to content

guiCreateFont

Client-side
Server-side
Shared

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

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

OOP Syntax Help! I don't understand this!

Syntax

gui-font|false guiCreateFont ( ​string filepath, [ ​int size = 9 ] )
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.

Returns

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

  • gui-font|false: result

Code Examples

client
-- Display a gui label
local myLabel = guiCreateLabel(100, 300, 400, 50, "GUI label", false)
-- Use 'toggle' command to switch custom font on and off
addCommandHandler("toggle", function()
if not myFont then
myFont = guiCreateFont("segoeui.ttf", 20) -- Create GUI custom font
guiSetFont(myLabel, myFont) -- Apply font to a widget
else
destroyElement(myFont) -- Destroy custom font
myFont = nil
end
end)

See Also

GUI Functions