DxCreateFont: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
Only available in 1.1 | Only available in 1.1 | ||
}} | }} | ||
This function creates a [[DX font]] element that can be used in [[dxDrawText]] | This function creates a [[DX font]] element that can be used in [[dxDrawText]]. Successful custom 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 '''VideoRamFreeForMTA''' is zero, failure ''is'' guaranteed.) | |||
=====It is highly recommended that [[dxSetTestMode]] is used when writing and testing scripts using dxCreateFont.===== | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 19: | Line 23: | ||
===Returns=== | ===Returns=== | ||
Returns a [[DX font]] element if successful, ''false'' if invalid arguments were passed to the function. | Returns a [[DX font]] element if successful, ''false'' if invalid arguments were passed to the function. | ||
'''You should always check to see if this function has returned false.''' | |||
==Example== | ==Example== |
Revision as of 06:06, 23 August 2011
Only available in 1.1 This function creates a DX font element that can be used in dxDrawText. Successful custom 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 VideoRamFreeForMTA is zero, failure is guaranteed.)
It is highly recommended that dxSetTestMode is used when writing and testing scripts using dxCreateFont.
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 DX font element if successful, false if invalid arguments were passed to the function.
You should always check to see if this function has returned false.
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 )
See Also
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTarget
- dxCreateScreenSource
- dxCreateShader
- dxCreateTexture
- dxDrawCircle
- dxDrawImage
- dxDrawImageSection
- dxDrawLine
- dxDrawLine3D
- dxDrawMaterialLine3D
- dxDrawMaterialPrimitive
- dxDrawMaterialPrimitive3D
- dxDrawMaterialSectionLine3D
- dxDrawPrimitive
- dxDrawPrimitive3D
- dxDrawRectangle
- dxDrawText
- dxDrawWiredSphere
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsSize
- dxGetPixelsFormat
- dxGetStatus
- dxGetTextSize
- dxGetTextWidth
- dxGetTexturePixels
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderValue
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource