guiCreateFont | Multi Theft Auto: Wiki Skip to content

guiCreateFont

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 GUI font element that can be used in guiSetFont. Successful font creation is not guaranteed, and may fail due to hardware or memory limitations.

OOP Syntax Help! I don't understand this!

Syntax

element 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

  • element: value

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

Code Examples

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