HU/dxCreateFont

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

Ez a function létrehoz egy DX font elemet, amely a dxDrawText-ben használható. A sikeres betűtípus létrehozása nem garantált, a hardver vagy a memória korlátai miatt hibák lehetnek.

Használja a dxGetStatus-t a hibák megtalálásához. (Ha a VideoMemoryFreeForMTA nulla, akkor a hiba garantált.)

Nagyon ajánlott, a dxSetTestMode használata, amikor a dxCreateFont-t használva írunk és tesztelünk scripteket.

Szintaxis

element dxCreateFont ( string filepath[, int size=9, bool bold=false, string quality="proof" ] )

OOP Syntax Help! I don't understand this!

Method: DxFont(...)


Kötelező paraméterek

  • filepath: the name of the file containing the font

Tetszőleges paraméterek

  • size: size of the font
  • bold: flag to indicate if the font should be bold
  • quality: the font quality
    • "default": not the actual default
    • "draft"
    • "proof": the default
    • "nonantialiased"
    • "antialiased"
    • "cleartype"
    • "cleartype_natural"

Visszatérési érték

Returns a DX 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.

Példa

local myFont = nil

-- Display text using dxDrawText
addEventHandler( "onClientRender", root,
    function()
        if myFont then
            dxDrawText( "dxDrawText", 100, 350, 300, 350, tocolor(255,255,0), 1, myFont )
        end
    end
)

-- Use 'toggle' command to switch custom font on and off
addCommandHandler( "toggle",
    function()
        if not myFont then
            myFont = dxCreateFont( "segoeui.ttf", 20 )  -- Create custom font
        else        
            destroyElement( myFont )                    -- Destroy custom font
            myFont = nil
        end
    end
)

Lásd még

Fordította