OSC 50 Set Font
Change xterm's font, or ask which one it is using.
OSC 50 ; Pt ST
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). 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), 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). 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). 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). The portable way to change the cursor is DECSCUSR. iTerm2 once used OSC 50 for its own commands as well, and moved them to OSC 1337 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, 2nd ed., 1984 | No | OSC is not among the controls it recognizes (§4.2) |
| VT510 | manual, 1st ed., 1993 | No | ignores an OSC string (chapter 4) |
| xterm | patch 412, xterm-411a | Yes | on unless allowFontOps is turned off |
| libghostty-vt | 0f171f6 | No | OSC50-1, OSC50-3: ignored; fonts are the host’s business |
| Konsole | 26.11.70, a24c3d71 | No | OSC 50 changes profile properties instead, such as CursorShape |
| ConEmu | build 230724, its documentation | No | not in ConEmu’s list, ANSI escape codes |
Validation
OSC50-1: Which font
\e]50;?\a
|______|
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
A
\e]50;9x15\a
\e]50;#+1\a
B
|AB____|
cursor 1,3
OSC50-3: Konsole’s cursor shape is a font xterm cannot load
\e]50;CursorShape=1\a
|______|
bell 1