dxGetTextWidth
Client
Measures how wide a text is on the screen, at its widest line.
float|false dxGetTextWidth(string text [, float scale = 1, string|element font = default, bool colorCoded = false])
Parameters
| Name | Type | Description |
|---|---|---|
| text | string | The text. |
| scale | float | Text scale.default 1 |
| font | string|element | A font's name (from a pack or given to dxCreateFont) or a font element from dxCreateFont.default default |
| colorCoded | bool | Leave #RRGGBB colour codes out of the measure.default false |
Returns
The width in pixels, or false when the font does not exist.
Example
local text = "Bem-vindo"
local width = dxGetTextWidth(text, 2, "default")
addEventHandler("onClientRender", root, function()
local sx = getScreenSize()
dxDrawText(text, (sx - width) / 2, 40, 0, 0, tocolor(255, 255, 255), 2)
end)