DxCreateFont
From Multi Theft Auto: Wiki
Note: The size can't be less than 5 or more than 150 |
This function creates a DX font element that can be used in dxDrawText. 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 dxCreateFont.
Syntax
element dxCreateFont ( string filepath[, int size=9, bool bold=false, string quality="proof" ] )
OOP Syntax Help! I don't understand this!
- Method: DxFont(...)
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
- quality: the font quality
- "default": not the actual default
- "draft"
- "proof": the default
- "nonantialiased"
- "antialiased"
- "cleartype"
- "cleartype_natural"
Returns
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.
Example
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 )
See Also
- dxConvertPixels
- dxCreateFont
- dxCreateRenderTarget
- dxCreateScreenSource
- dxCreateShader
- dxCreateTexture
FROM VERSION 1.5.7 r19626 ONWARDS
- dxDrawMaterialSectionLine3D
- dxDrawRectangle
- dxDrawText
- dxGetBlendMode
- dxGetFontHeight
- dxGetMaterialSize
- dxGetPixelColor
- dxGetPixelsSize
- dxGetPixelsFormat
- dxGetStatus
- dxGetTextWidth
- dxGetTexturePixels
- dxIsAspectRatioAdjustmentEnabled
- dxSetAspectRatioAdjustmentEnabled
- dxSetBlendMode
- dxSetPixelColor
- dxSetRenderTarget
- dxSetShaderValue
- dxSetShaderTessellation
- dxSetShaderTransform
- dxSetTestMode
- dxSetTextureEdge
- dxSetTexturePixels
- dxUpdateScreenSource