GuiCreateFont

From Multi Theft Auto: Wiki
Revision as of 15:45, 17 April 2021 by EOFIK (talk | contribs) (Добавление языков)
Jump to navigation Jump to search

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.

To see if creation is likely to fail, use dxGetStatus. (When VideoMemoryFreeForMTA is zero, failure is guaranteed.)

It is highly recommended that dxSetTestMode is used when writing and testing scripts using guiCreateFont .

Syntax

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

OOP Syntax Help! I don't understand this!

Method: GuiFont(...)


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, or there is insufficient resources available.

You should always check to see if this function has returned false.

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

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows

Input

GUI