Difference between revisions of "GuiCreateFont"

From Multi Theft Auto: Wiki
Line 4: Line 4:
 
Only available in 1.1
 
Only available in 1.1
 
}}
 
}}
This function creates a [[Gui_Font|GUI font]] element that can be used in [[guiSetFont]]
+
This function creates a [[GUI font]] element that can be used in [[guiSetFont]]
 
==Syntax==  
 
==Syntax==  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
Line 17: Line 17:
  
 
===Returns===
 
===Returns===
Returns a [[Gui_Font|GUI font]] element if successful, ''false'' if invalid arguments were passed to the function.
+
Returns a [[GUI font]] element if successful, ''false'' if invalid arguments were passed to the function.
  
 
==Example==  
 
==Example==  

Revision as of 20:07, 24 June 2011

Only available in 1.1 This function creates a GUI font element that can be used in guiSetFont

Syntax

element guiCreateFont ( string filepath[, int size=9 ] )

Required Arguments

  • filepath: the name of the file containing the font

Optional Arguments

  • size: size of the font

Returns

Returns a GUI font element if successful, false if invalid arguments were passed to the function.

Example

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