DxGetTextWidth: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 29: | Line 29: | ||
outputChatBox(tostring(length)) | outputChatBox(tostring(length)) | ||
end | end | ||
addEventHandler(" | addEventHandler("onClientPlayerChat",getRootElement(),dxwidth) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | </section> |
Revision as of 21:37, 1 June 2011
This function retrieves the theoretical width of a certain piece of text, if it were to be drawn using dxDrawText.
Syntax
float dxGetTextWidth ( string text, [float scale=1, string font="default"] )
Required Arguments
- text: A string representing the text for which you wish to retrieve with width for.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- scale: The size of the text.
- font: The dx font for the text.
- "default": Tahoma
- "default-bold": Tahoma Bold
- "clear": Verdana
- "arial": Arial
- "sans": Microsoft Sans Serif
- "pricedown": Pricedown (GTA's theme text)
- "bankgothic": Bank Gothic Medium
- "diploma": Diploma Regular
- "beckett": Beckett Regular
- "unifont": Unifont
Returns
Returns the float of the width of the text.
Example
Click to collapse [-]
ExampleThis will show you the width of a message in a normal chatbox sent by a player
function dxwidth(msg) chatbox = getChatboxLayout() local length = dxGetTextWidth(msg,chatbox["chat_scale"][1]) outputChatBox(tostring(length)) end addEventHandler("onClientPlayerChat",getRootElement(),dxwidth)
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