Moth

Glyph Protocol

Display application-provided vector glyphs, negotiate support, and use the glyf format.

Application-provided glyphs

Glyph Protocol lets a terminal application register vector outlines for its session. Moth renders them at the terminal’s current font size, using the text foreground colour, without installing a font or replacing existing text and Nerd Font icons. Each PTY has its own temporary glossary.

Moth supports the monochrome OpenType glyf format. Payload formats are negotiated; SVG path payloads, colour OpenType glyphs, composite outlines, and hinting bytecode are not accepted. See the protocol specification for the wire format.

Run an example

Download the Python example, then run it in a Moth pane:

python3 glyph-protocol.py

It negotiates glyf support, registers a simple star outline, and prints it in colour. It uses Python’s standard library and requires a terminal for input and output. The outline stays available in that session until it is replaced, cleared, or removed by a full terminal reset.

Negotiate before registering

Messages use APC framing: ESC _ 25a1;... ESC \. Send the support probe before sending a payload:

ESC _ 25a1;s ESC \

Moth replies with 25a1;s;fmt=glyf in the same framing. Check the comma-separated fmt field for glyf. A client should stop if the terminal does not advertise a compatible format.

The verbs are s for support, q for coverage queries, r for registration, and c for clearing registrations. Queries report font and glossary coverage. Grapheme queries are not advertised. Registration and clear messages accept reply=0, 1, or 2, as defined by the protocol.

Sizing and colour

Registrations support the protocol’s advance width, line height, alignment, padding, and one- or two-cell drawing hints. A two-cell drawing hint can extend into the following blank cell; it does not change cursor advance, wrapping, or selection.

A glyf outline uses the cell’s foreground colour, so an application can recolour it with ordinary SGR colour sequences. Replacing or clearing a registration updates existing cells and scrollback as well as later output.

Session limits

The glossary covers 1,024 codepoints, U+100000 through U+1003FF. Each decoded glyph is limited to 32 KiB and 5,461 points, and the session has a shared point budget. Exhausting it reports no_space. Coverage queries are limited to 128 per second.

Registrations stay with the PTY and are not installed as system fonts or saved in profiles. A full terminal reset clears the glossary. Codepoints outside the reserved range cannot be registered.