^[control-codes
live in libghostty-vt

Operating system commands

OSC 50 Set Font

View as Markdown

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

OSC 50 ; Pt ST
ECMA-48
§8.3.89 OSC – Operating System Command, p. 51
xterm
Operating System Commands

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

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984NoOSC is not among the controls it recognizes (§4.2)
VT510manual, 1st ed., 1993Noignores an OSC string (chapter 4)
xtermpatch 412, xterm-411aYeson unless allowFontOps is turned off
libghostty-vt0f171f6NoOSC50-1, OSC50-3: ignored; fonts are the host’s business
Konsole26.11.70, a24c3d71NoOSC 50 changes profile properties instead, such as CursorShape
ConEmubuild 230724, its documentationNonot 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
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.