# dxCreateFont (Client)

> Creates a font from a font file in the resource, for the text functions.

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

## Syntax

```lua
element|false dxCreateFont(string filepath [, int size = 9, bool bold = false, string quality = proof, string name = ""])
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `filepath` | `string` | Path of the font file (for example `.ttf`). |
| `size` | `int` | Size, from 5 to 150. Values outside are clamped. *(default: `9`)* |
| `bold` | `bool` | Use bold. *(default: `false`)* |
| `quality` | `string` | Quality: `default`, `draft`, `proof`, `nonantialiased`, `antialiased`, `cleartype` or `cleartype_natural`. Only `nonantialiased` turns smoothing off. *(default: `proof`)* |
| `name` | `string` | Name to use the font by in the text functions, as a string. Empty makes an unnamed font. *(default: `""`)* |

## Returns

The font element, or `false` when the file could not be read or the font could not be made.

## Example

```lua
local title = dxCreateFont("fonts/Montserrat-Bold.ttf", 18, false, "antialiased", "title")

addEventHandler("onClientRender", root, function()
    dxDrawText("MYMP", 20, 20, 0, 0, tocolor(255, 255, 255), 1, title)
    dxDrawText("Roleplay", 20, 60, 0, 0, tocolor(255, 255, 255), 1, "title")
end)
```

## See also

- [dxDrawText (Client)](https://wiki.mymp.gg/en/dxDrawText.md): Draws text on the screen for one frame, inside a box.
- [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.
- [destroyElement (Shared)](https://wiki.mymp.gg/en/destroyElement.md): Destroys an element and all of its children. Before it goes, each one fires onElementDestroy on the server or onClientElementDestroy on the client.
