# Javascript: Selection.setFontName Method

> Sets the font's name of the selected text.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 26.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: Selection.setFontName Method
- **329 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/selection/setfontname-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/selection/setfontname-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/selection/setfontname-method/llms-full.txt

---

### Description

Sets the font's name of the selected text.

### Syntax

```javascript
<void> Selection.setFontName(<string> fontName, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| fontName | The font's name of the selected text. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `Selection.setFontName` in a practical document-editing workflow. It sets the font's name of the selected text.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.selection.setFontName(
    "Arial",
    function() {
        console.log("set font name completed.");
    },
    onTxError
);
```

---

## Nearby

- **Previous:** [Javascript: Selection.setCulture Method](https://docs.textcontrol.com/ds-server/reference/javascript/selection/setculture-method/llms-full.txt)
- **Next:** [Javascript: Selection.setFontSize Method](https://docs.textcontrol.com/ds-server/reference/javascript/selection/setfontsize-method/llms-full.txt)
