Terminal rendering: lessons from the COSMIC fixes
Recorded 2026-11-05, after fixing disconnected borders, Powerline seams, and emoji fallback in local COSMIC Terminal and cosmic-text checkouts. This is guidance for Voyager7's planned D3D11/DirectWrite renderer, not a claim that Voyager7 already implements or passes these checks.
Voyager7 draws box drawing, block elements, shades and Powerline arrows itself
(U+2500 to U+259F, U+E0B0 to U+E0B3) as cell-sized sprites by default, like Ghostty,
Windows Terminal, Alacritty and kitty, so they join at every font, size and scale.
A config switch turns this off to use the font's own shapes (owner decision,
2026-11-06). Every other character keeps the selected font's glyph shape: fix
metrics, shaping, placement, and compositing at the shared rendering layer rather
than hiding a problem there with hand-drawn substitutes. The COSMIC fix removed its
custom box-drawing replacement because it masked a placement bug; with the uniform
integer cell grid in v7-core, sprites no longer hide such bugs. Rectangles for cell
backgrounds, selections, cursors, and text decorations are a separate concern.
Keep the layers separate
VT bytes -> libghostty-vt cells and attributes
-> grapheme shaping and font fallback
-> physical-pixel placement and glyph rasterization
-> background/glyph compositing -> display
Using libghostty-vt does not give Voyager7 Ghostty's font resolver or renderer. The existing VT corpus checks terminal state; it cannot prove that glyphs connect, emoji have the right presentation, or GPU pixels are correct. The renderer needs its own tests.
What failed and what fixed it
| Symptom | Cause in the COSMIC investigation | Lesson for Voyager7 |
|---|---|---|
| Vertical borders looked dashed | Row spacing used an arbitrary font-size multiplier instead of the selected font's line metrics. Hinting also affected cell-spanning outlines. | Derive the grid and baseline from actual font metrics; test hinting with the chosen rasterizer. |
| Repeated horizontal borders had visible bands | Overlapping outlines were antialiased independently, then their partial coverage accumulated. | Correct geometry/coverage before final blending; moving glyphs alone does not fix double-covered edges. |
| Powerline arrows retained a thin vertical seam | Fractional glyph advances met backgrounds whose origins and widths were rounded separately in logical pixels. | Use a shared physical-pixel grid for font geometry, glyph placement, and background edges. |
| Emoji appeared monochrome or used the wrong fallback | Unrelated symbol/monospace fonts won fallback before the appropriate emoji font. | Resolve presentation and fallback deliberately, not by the first font containing the code point. |
| Emoji spacing drifted | A pixel advance was rounded using an em-based width. | Keep units explicit and preserve terminal cell allocation through shaping. |
| COSMIC used Noto while other apps used Apple emoji | Its built-in fallback order overrode the desktop's emoji preference. | Separate system/user font preference from the renderer's built-in last resorts. |
Metrics and physical pixels
-
Use one grid for glyphs, backgrounds, cursor, selection, decorations, and input coordinates. Snap the viewport origin as well as cell boundaries.
-
Round both absolute edges of a rectangle, then subtract. Do not round its origin and width independently. With display scale
s:left_px = round((origin + start) * s) right_px = round((origin + end) * s) width_px = right_px - left_px -
Voyager7's policy (
v7-core, 2026-11-06): the cell size is rounded to whole physical pixels once,cell_w = round(advance * s)andcell_h = round((ascent + descent + line_gap) * s); the viewport origin snaps once,origin_px = round(origin * s); every edge isorigin_px + index * cell_size. All cells are identical, so instanced quads, the glyph atlas and box-drawing sprites share one cell size, and the rule above holds because both edges are integers. The font is scaled uniformly byglyph_scale = cell_w / (advance * s)to fit. -
The COSMIC fix rounded the physical cell width, then scaled the whole font uniformly to fit that width. Merely changing the advance left native outlines crossing fractional cell edges. This is one tested policy, not a requirement to copy that exact rasterizer setup into DirectWrite.
-
Measure an unconstrained font when changing size. COSMIC's measurement needed a fresh buffer so the previous forced monospace width did not feed back into the next zoom measurement.
-
Recompute metrics and invalidate affected caches when font, size, weight, stretch, or display scale changes. Do not mix logical units, physical pixels, em fractions, and UTF-16 offsets in unnamed values.
-
Do not disable DirectWrite hinting blindly because disabling Swash hinting helped COSMIC. Prove the behavior with DirectWrite and the actual Windows font. A font whose artwork intentionally leaves space will not necessarily connect under every grid policy.
Coverage, colors, and caching
The COSMIC fix combined compatible overlapping font outlines before antialiasing. It used geometric tessellation to resolve the overlap; simply concatenating paths did not remove the artifact. Counter holes, winding, and glyph overhangs must survive this operation.
Do not merge unrelated colors, fonts, or layers as though they were one outline. Preserve draw order. Test partially transparent text as well as opaque text.
Monochrome glyph masks take the foreground color. Color emoji retain their own colors; do not tint them as monochrome masks. Define whether texture pixels are straight or premultiplied alpha and keep upload, shader, and blend state consistent. Likewise, decide the blend color space explicitly. Ghostty's linear-corrected blending is useful prior art, but changing gamma does not repair a geometric gap.
Cache keys must distinguish everything that changes the raster: font face and variation, size at the physical scale, weight/style or synthesis, hinting/rendering mode, and subpixel position. Include colors/palette when caching colored output. An integer translation can often reuse an image; a changed subpixel origin cannot automatically do so. Keep GPU allocations alive through submission and bound cache growth when users zoom or switch fonts.
Emoji presentation is separate from emoji artwork
Resolve each extended grapheme cluster as a unit. Keep variation selectors, skin tones, regional-indicator pairs, and ZWJ sequences attached to their characters. Splitting a shaping run must not let one cluster's selector affect its neighbor. Use the VT engine's cell allocation; glyph count, UTF-8 byte count, UTF-16 code-unit count, and terminal column count are different quantities.
| Input | Meaning / tested COSMIC policy |
|---|---|
U+26A1 (⚡), no selector | Unicode defaults to emoji presentation. The fixed COSMIC policy nevertheless preserves the explicitly selected primary font's glyph when it has one; this kept Caskaydia's plain lightning. |
U+26A1 U+FE0E | Request text presentation. |
U+26A1 U+FE0F | Request emoji presentation, then choose an appropriate emoji font. |
😀, 👍🏽, 👩💻, 🇯🇵 | Resolve and shape whole emoji clusters, with consistent cell allocation. |
No FE0F does not mean “must be monochrome.” Bare lightning is emoji-default
in Unicode's data.
Rexnux's colored bare lightning was not by itself a Unicode bug. Keep this
distinction explicit when defining Voyager7's policy. See
Unicode presentation rules.
Font selection then chooses the artwork:
- Rexnux used Pango/Fontconfig and picked the installed Apple Color Emoji.
- Ghostty's Linux renderer included a bundled Noto emoji fallback. Sharing its VT engine did not make Rexnux share that font choice.
- COSMIC originally preferred its built-in Noto entry. The fix queried Fontconfig's
emojipreference once per font system, ahead of built-in fallbacks, while retaining explicit font choices and selector behavior. A temporary Noto override was tested too: the fix followed the preference, not a hard-coded Apple name.
For Voyager7, use a Windows-appropriate resolver or explicit configurable fallback list. Do not add Fontconfig just to imitate the Linux fix. Query/cache preferences outside the per-frame path, distinguish missing glyphs from unsupported color-font formats, and retain a usable fallback. A family name containing “Emoji” is not a substitute for checking glyph and format support.
Windows 7 needs a deliberate color-font plan
The presence of dwrite.dll on Windows 7 does not establish color-emoji support.
Microsoft lists Windows 8.1 as the minimum client for
IDWriteFactory2::TranslateColorGlyphRun.
Do not assume newer DirectWrite interfaces or a particular emoji font are present
on a stock Windows 7 installation. Capability-check newer paths and define the
Windows 7 color-glyph implementation or fallback before promising color emoji.
Test the selected font formats, not just whether the font can be enumerated.
Renderer acceptance checks
Turn these into pixel/shape tests when implementing roadmap step 2. Keep the input bytes, font identity, font file/version, size, scale, and renderer backend with each result so a failure can be reproduced.
- Light, heavy, and double borders; corners, intersections, and long repeated horizontal/vertical runs. Assert coverage does not oscillate at cell boundaries.
- Left/right Powerline arrows joining contrasting backgrounds, at different columns and fractional viewport origins. Check both sides of the stem and verify the arrow was actually drawn; a blank image must not pass.
- Several sizes (COSMIC checked 10, 12, 16, 20, 24) and scales (100%, 125%, 150%, 200%), regular and bold. Test zooming back and forth and supported DPI changes.
- The selector cases above, alternating text/emoji hearts, skin tones, flags, and joined emoji. Assert selected font, monochrome versus color raster, glyph/cell allocation, and visible pixels—not just “shaping succeeded.”
- Preferred emoji font installed, absent, and overridden; a font missing a
requested glyph; regular emoji in bold text. Deterministic tests need small
licensed fixtures; separately test real installed fonts. COSMIC's
CosmicTestEmoji.ttfwas a test-only subset, not a runtime font substitution. - Overlapping outlines with counters (such as repeated
A), different colors, alpha, clipping, scrolling, cache reuse, and cache invalidation. - Actual GPU output, plus any software/reference renderer. Validate both dark and light backgrounds. For Voyager7, run the final rendering checks on real Windows 7 as well as newer Windows; Linux COSMIC results are not Win7 validation.
Local implementation references
These are local commits, not published upstream. The checkouts used here are
~/repo/pop-os/cosmic-term and ~/repo/pop-os/cosmic-text.
Ghostty and Rexnux comparisons used ~/repo/ghostty-org/ghostty and
~/repo/m-i-z-u-k-i/rexnux, respectively. Their renderer details are not a promise
about Voyager7's pinned libghostty-vt version or its future renderer.
| Repository / commit | What to inspect |
|---|---|
cosmic-term a029386 | Native line metrics and preservation of rasterizer flags; the custom box-drawing replacement was removed. |
cosmic-term a3434db | src/glyph_compositor.rs: outline overlap, color preservation, cache behavior, and GPU/software pixel tests. |
cosmic-term ec2b28b | src/font_grid.rs, src/terminal_box.rs: physical grid, shared background edges, font/DPI changes, and installed-font regressions. |
cosmic-term e9ca042 | Lockfile integration of the system emoji preference fix. |
cosmic-text 790c900d | src/shape.rs, src/font/fallback/mod.rs, tests/emoji_fallback.rs: presentation runs, fallback order, and pixel/em advance correction. |
cosmic-text 2c9d3bad | src/font/fallback/unix.rs: system emoji preference; additional selection and installed-font tests. |
Voyager7's reusable visual input is
tests/visual/unicode.ans, a generated UTF-8
fixture covering scripts, styles and glyphs. Run it with demo unicode through
the cmd, PowerShell or Bash runner in tests/visual/; see the
demo instructions for usage and capture.
Fixtures preserve raw escape bytes and CRLF. The cmd runner is ASCII-only with
CRLF to avoid Windows 7 batch parsing problems under code page 65001.
Focused commands in the COSMIC checkouts are:
# In the cosmic-term checkout:
cargo test --bin cosmic-term
COSMIC_TERM_TEST_FONT=/path/to/a/Powerline-font.ttf \
cargo test --bin cosmic-term installed_font -- --ignored
# In the cosmic-text checkout:
cargo test --lib --test emoji_fallback
COSMIC_TEXT_TEST_EMOJI_FAMILY='Installed Emoji Family' \
COSMIC_TEXT_TEST_MONO_FAMILY='Installed Monospace Family' \
cargo test --test emoji_fallback installed_system -- --ignored
Those commands validate the COSMIC implementations. They are references for Voyager7 tests, not a replacement for testing its eventual DirectWrite renderer.
Shipping emoji policy (2026-11-07)
Voyager7 ships Noto Color Emoji (CBDT) and Noto Emoji (TrueType outlines) in
fonts/, alongside Cascadia Mono and their OFL licenses. Explicit families stay
first. Emoji presentation then follows the Windows system color preference,
Segoe UI Emoji, followed by platform/installed fonts and finally Noto Color.
On Win7, where no system color emoji face exists, Noto Color precedes monochrome
platform symbol fonts. VS15/default-text keep the existing platform and installed
order, with monochrome Noto last. Missing newer emoji fall through. With the
Noto color sidecar present, emoji
coverage also requires one non-missing shaped glyph for the whole cluster, using
the pinned HarfRust shaper without font fallback. Segoe split flags/tag sequences
and split ZWJ pieces therefore fall through to Noto without font-name rules.
Without sidecars the historical fallback behavior is unchanged. This mirrors the
ordering principle in cosmic-text 2c9d3bad, read as prior art only.
Resolution reassembles complete graphemes across VT cell payloads while preserving terminal cell allocation. Text fallback checks the shaped glyph artwork so VS15 remains monochrome. Sidecar OS/2 Unicode range bits are advisory: Noto's are incomplete, so its cmap is checked directly before accepting a face. New live emoji trigger resolution and frame-cache replacement while retaining selection; ordinary ASCII digits do not. Color artwork retains its RGB and text masks retain foreground tint. No approved fixture or golden is replaced. The manifest records upstream pins, hashes, Ghostty provenance, actual Swash support and candidate reproduction commands.