# 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)),
but it answers with the full name the X server gives the font it loaded,
and in a UTF-8 locale it loads the ISO 10646 version: with X.Org's standard
fonts, `-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1`. That is what this site's VM tests see, and what the case
expects; on another X server the name may differ. Changing the font changes
the size of the window, not the number of rows and columns.

**Konsole's profile changes.** Konsole uses `OSC 50` for something else:
`OSC 50 ; key=value ; key=value ST` changes properties of the session's
profile, and a comment in its source owns that this clashes with xterm's font
command ([`Session.h`](https://invent.kde.org/utilities/konsole/-/blob/a24c3d71be3684f24d030aa2dbe9bd723d985233/src/session/Session.h#L476)). The keys are the
names of profile properties, and four that change the cursor take effect at
once: `CursorShape`, `0` a block, `1` a bar and `2` an underline,
`BlinkingCursorEnabled`, `AnimatingCursorEnabled` and `CustomCursorColor`
([`Vt102Emulation.cpp`](https://invent.kde.org/utilities/konsole/-/blob/a24c3d71be3684f24d030aa2dbe9bd723d985233/src/Vt102Emulation.cpp#L1586-1670)). So
`OSC 50 ; CursorShape=1 ST`, which editors have been set up to send to get a
bar cursor in insert mode, is a font request to xterm: it tries to load a
font named `CursorShape=1`, fails, and rings the bell
([`SetVTFont`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/fontutils.c#L5441-L5518)). The portable way to change the
cursor is [DECSCUSR](https://control-codes.page/csi/decscusr/index.html.md). iTerm2 once used `OSC 50` for its own
commands as well, 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, Konsole's form included: fonts
are its host's business. The case that asks, and the one where xterm rings
the bell, are known differences.

## Support

| Terminal | Version | Support | Notes |
| --- | --- | --- | --- |
| VT220 | [manual](https://vt100.net/docs/vt220-rm/), 2nd ed., 1984 | No | OSC is not among the controls it recognizes ([§4.2](https://vt100.net/docs/vt220-rm/chapter4.html#S4.2)) |
| VT510 | [manual](https://vt100.net/docs/vt510-rm/), 1st ed., 1993 | No | ignores an OSC string ([chapter 4](https://vt100.net/docs/vt510-rm/chapter4.html)) |
| xterm | patch 412, [xterm-411a](https://github.com/ThomasDickey/xterm-snapshots/tree/xterm-411a) | Yes | on unless `allowFontOps` is turned off |
| libghostty-vt | [0f171f6](https://github.com/ghostty-org/ghostty/tree/0f171f650a1cbbd6df4a2573b6b0c7de57cc6d90) | No | OSC50-1, OSC50-3: ignored; fonts are the host's business |
| Konsole | 26.11.70, [a24c3d71](https://invent.kde.org/utilities/konsole/-/tree/a24c3d71be3684f24d030aa2dbe9bd723d985233) | No | `OSC 50` changes profile properties instead, such as `CursorShape` |
| ConEmu | build 230724, its [documentation](https://conemu.github.io/en/AnsiEscapeCodes.html) | No | not in ConEmu's list, [ANSI escape codes](https://conemu.github.io/en/AnsiEscapeCodes.html) |

## 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;-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1\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
```

### OSC50-3: Konsole's cursor shape is a font xterm cannot load

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

Input, one step per line:

```text
\e]50;CursorShape=1\a
```

Expected screen:

```text
|______|
bell 1
```

---

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>.
