DxCreateFont: Difference between revisions
Jump to navigation
Jump to search
m (moved CreateFont to DxCreateFont: Function split) |
No edit summary |
||
Line 4: | Line 4: | ||
Only available in 1.1 | Only available in 1.1 | ||
}} | }} | ||
This function creates a font element that can be used in | This function creates a font element that can be used in [[dxDrawText]] | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
element | element dxCreateFont ( string filepath[, int size=9, bool bold=false ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 15: | Line 15: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
*'''size:''' size of the font | *'''size:''' size of the font | ||
*'''bold:''' flag to indicate if the font should be bold | *'''bold:''' flag to indicate if the font should be bold | ||
===Returns=== | ===Returns=== | ||
Returns a [[font]] [[element]] if successful, ''false'' if invalid arguments were passed to the function. | Returns a [[DX_Font|font]] [[element]] if successful, ''false'' if invalid arguments were passed to the function. | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- Display text using dxDrawText | -- Display text using dxDrawText | ||
addEventHandler( "onClientRender", root, | addEventHandler( "onClientRender", root, | ||
Line 36: | Line 33: | ||
function() | function() | ||
if not myFont then | if not myFont then | ||
myFont = | myFont = dxCreateFont( "segoeui.ttf", 20 ) -- Create custom font | ||
else | else | ||
destroyElement( myFont ) | destroyElement( myFont ) -- Destroy custom font | ||
myFont = nil | myFont = nil | ||
end | end |
Revision as of 03:05, 19 June 2011
Only available in 1.1 This function creates a font element that can be used in dxDrawText
Syntax
element dxCreateFont ( string filepath[, int size=9, bool bold=false ] )
Required Arguments
- filepath: the name of the file containing the font
Optional Arguments
- size: size of the font
- bold: flag to indicate if the font should be bold
Returns
Returns a font element if successful, false if invalid arguments were passed to the function.
Example
-- Display text using dxDrawText addEventHandler( "onClientRender", root, function() dxDrawText( "dxDrawText", 100, 350, 300, 350, tocolor(255,255,0), 1, myFont ) 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 )