# Set Font (OSC 50)

> Change xterm's font, or ask which one it is using.

- **Sequence:** `OSC 50 ; Pt ST`
- **ECMA-48:** [§8.3.89 OSC – Operating System Command, p. 51](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n64/mode/1up)
- **xterm:** [Operating System Commands](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

`OSC 50 ; Pt ST` changes xterm's font to `Pt`, an X font name such as
`fixed` or `9x15`, and `OSC 50 ; ? ST` asks which font it is using. `Pt` can
instead begin with `#` and an entry in xterm's font menu: `#3` for the third
entry, `#+1` for the next one, `#-1` for the one before. A query is answered
`OSC 50 ; name ST`, and a query for another menu entry, `OSC 50 ; ?+1 ST`,
names the entry as well as its font
([`QueryFontRequest`, `ChangeFontRequest`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L3798-L3932)).
When xterm is using a TrueType font, set with `-fa` or its menu, the same
sequence sets and queries its face name instead.

A default xterm allows both: font operations are on unless the
`allowFontOps` resource turns them off. Its font is `fixed` unless a
resource says otherwise
([`DEFFONT`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/main.h#L62-L63)),
and that is what the case expects it to report. Changing the font changes
the size of the window, not the number of rows and columns.

iTerm2 once used `OSC 50` for its own commands and moved them to
[`OSC 1337`](https://control-codes.page/osc/iterm2/index.html.md) because of this clash.

libghostty-vt has no `OSC 50`, and ignores it: fonts are its host's
business. The case that asks is a known difference.

## Validation

### OSC50-1: Which font

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
\e]50;?\a
```

Expected screen:

```text
|______|
reply \e]50;fixed\a
```

### OSC50-2: Changing the font leaves the screen as it was

Input, one step per line:

```text
A
\e]50;9x15\a
\e]50;#+1\a
B
```

Expected screen:

```text
|AB____|
cursor 1,3
```

---

This is the Markdown version of <https://control-codes.page/osc/font/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
