Skip to main content
ansicode

OSC 50 — Set or query font (xterm font selector)

Switch the terminal's display font at runtime, or query the current font — xterm extension, also implemented by a handful of forks.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b]50;FONT-SPEC\x07 (set) \x1b]50;?\x07 (query)
\\033[\033]50;FONT-SPEC\007
\\e[\e]50;FONT-SPEC\a
ESC [ESC ] 50 ; FONT-SPEC BEL
hex1b 5d 35 30 3b ... 07

Description

OSC 50 switches the terminal's display font at runtime. The argument is a font specification understood by the terminal — historically an XLFD (`-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1`), modern xterm and forks also accept Xft / fontconfig names (`monospace:size=14`, `Iberian Black:size=12:weight=bold`). A leading `+N`/`-N` instead of a name shifts the size up/down by N pixels relative to current. Sending `?` (`\x1b]50;?\x07`) makes the terminal reply with the current font name as `\x1b]50;NAME\x07` — used by `vim`'s `:set guifont` autodetect equivalent and by `xterm`'s font menu. urxvt added a parallel OSC 710 / 711 / 712 for its own font/boldFont/italicFont slots. Modern non-xterm terminals (kitty, alacritty, wezterm, ghostty, Windows Terminal, iTerm2) all manage fonts via their own config — they don't honour OSC 50 because there's no single 'default font' to override.

Spec citation: xterm-ctlseqs (OSC 50)

Examples

bash
printf '\033]50;monospace:size=18\007'   # bump to 18pt monospace\nprintf '\033]50;?\007'                   # query current font name
python
import sys; sys.stdout.write('\x1b]50;monospace:size=18\x07')
go
fmt.Print("\x1b]50;monospace:size=18\x07")
javascript
process.stdout.write('\x1b]50;monospace:size=18\x07')
c
printf("\x1b]50;monospace:size=18\x07");

Terminal support

xterm
yes
Linux console (fbcon)
no
macOS Terminal.app
no
iTerm2
no
Windows Terminal
no
cmd.exe / ConPTY
no
kitty
no
alacritty
no
WezTerm
no
Ghostty
no
GNOME Terminal
no
Konsole
no
tmux
no
GNU screen
no

Related sequences