跳到主要内容
ansicode

DECDLD — 动态可重定义字符集(DCS ... { ... ST)

把软字模位图下载到终端的某个槽位,便可与内置字体并列显示 —— DEC VT220+ 纯遗留特性。

字节形式

涵盖所有常见的字符串字面量写法,方便正反查找。

\\x1b[\x1bPPfn;Pcn;Pe;Pcms;Pw;Pt{Dscs Sxbp1;Sxbp2;...\x1b\\
\\033[\033PPfn;Pcn;Pe;Pcms;Pw;Pt{Dscs ...\033\\
\\e[\ePPfn;Pcn;Pe;Pcms;Pw;Pt{Dscs ...\e\\
ESC [ESC P Pfn ; Pcn ; Pe ; Pcms ; Pw ; Pt { Dscs SIXEL-DATA ESC \
hex1b 50 ... 7b ... 1b 5c

说明

DECDLD —— Dynamically Redefinable Character Set。DCS 帧的体是 6 个参数的头部,随后是字面 `{`(0x7b),再是命名 Dynamic Soft Character Set 的末字节,最后是逐字模的 sixel 位图(`/` 表示列断、`;` 表示下一字模)。**Pfn** = 字模编号、**Pcn** = 槽内起始字符码、**Pe** = 擦除控制(0 = 全部擦除、2 = 只擦即将重定义的)、**Pcms** = 字模点阵大小、**Pw** = 字模宽度(5 = 80 列、6 = 132 列)、**Pt** = 文本/全格模式。载荷与 `dcs-sixel` 共用 `?`..`~` 字母表,但每字节编码一字模格内的 6 像素竖向条。xterm、vttest 与 `tek4014` 模拟器解码;现代终端普遍忽略 —— 它们的字体来自操作系统字体系统,没有「按会话槽位」的位图概念。今日仍相关的场景:终端规范作者(vttest 的字模编辑页)、历史 VT 保育项目、需为兼容测试实现 DECDLD 解析的模拟器开发者。

规范出处: DEC STD 070 (DECDLD)

示例

bash
# Define one tiny glyph at code 41 (capital 'A') in font slot 1 — payload is a 1-cell sixel.\nprintf '\033P1;41;0;15;0;0{ @???A;????\033\\'
python
import sys; sys.stdout.write('\x1bP1;41;0;15;0;0{ @???A;????\x1b\\\\')
go
fmt.Print("\x1bP1;41;0;15;0;0{ @???A;????\x1b\\\\")
javascript
process.stdout.write('\x1bP1;41;0;15;0;0{ @???A;????\x1b\\\\')
c
printf("\x1bP1;41;0;15;0;0{ @???A;????\x1b\\\\");

终端支持

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

相关序列

在家族食谱中

DCS 食谱 · 4. VT 重映射面 —— DECUDK(用户自定义键)与 DECDLD(下载字形)