# dxGetTextSize (Client)

> Measures the width and height a text takes on the screen.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Client
- **Category**: Screen drawing
- **URL**: https://wiki.mymp.gg/en/dxGetTextSize

## Syntax

```lua
float, float|false dxGetTextSize(string text [, float width = 0, float scaleX, scaleY = 1, string|element font = default, bool wordBreak = false, bool colorCoded = false])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `text` | `string` | The text. |
| `width` | `float` | Available width in pixels, used with `wordBreak`. *(default: `0`)* |
| `scaleX, scaleY` | `float` | Text scale. One number applies to both axes. A vec2 also works. *(default: `1`)* |
| `font` | `string\|element` | A font's name (from a pack or given to `dxCreateFont`) or a font element from `dxCreateFont`. *(default: `default`)* |
| `wordBreak` | `bool` | Wrap lines that do not fit in `width`. *(default: `false`)* |
| `colorCoded` | `bool` | Leave `#RRGGBB` colour codes out of the measure. *(default: `false`)* |

## Returns

The width and height in pixels, or `false` when the font does not exist.

## Example

```lua
local text = "A long description that has to wrap over several lines."
local w, h = dxGetTextSize(text, 300, 1, "default", true)

addEventHandler("onClientRender", root, function()
    dxDrawRectangle(20, 20, w + 20, h + 20, tocolor(0, 0, 0, 160))
    dxDrawText(text, 30, 30, 330, 30 + h, tocolor(255, 255, 255), 1, "default", "left", "top", false, true)
end)
```

## See also

- [dxGetTextWidth (Client)](https://wiki.mymp.gg/en/dxGetTextWidth.md): Measures how wide a text is on the screen, at its widest line.
- [dxGetFontHeight (Client)](https://wiki.mymp.gg/en/dxGetFontHeight.md): Returns the height of one line of text in a font.
- [dxDrawText (Client)](https://wiki.mymp.gg/en/dxDrawText.md): Draws text on the screen for one frame, inside a box.
