Add lineHeight to ITerminalOptions

Abierto
#216 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
typescript
Área
api, frontend

Línea de trabajo

Start with ITerminalOptions, CanvasRenderer.measureFont(), charHeight, and remeasureFont() named in the issue. Read xterm.js 6.0’s lineHeight behavior and coordinate with the open issues #207, #146, and #126 because they touch related font metrics. Done means lineHeight is a runtime option with the stated default and multiplier behavior, glyphs remain centered, and the related metric changes are accounted for.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

What's missing

There's no way to adjust line spacing. lineHeight appears nowhere in the published bundle, and the cell height is fixed by CanvasRenderer.measureFont():

const m = ctx.measureText("M"),
  ascent  = m.actualBoundingBoxAscent  || this.fontSize * 0.8,
  descent = m.actualBoundingBoxDescent || this.fontSize * 0.2,
  height  = Math.ceil(ascent + descent) + 2,   // the only leading, hardcoded
  baseline = Math.ceil(ascent) + 1;

charHeight returns metrics.height, and ITerminalOptions exposes fontSize and fontFamily but nothing for spacing — so there's no public knob and nothing private to reach for either.

Why

@xterm/xterm 6.0 has lineHeight?: number (xterm.d.ts:150), and xterm.js API compatibility is an explicit goal here — so this reads as a gap in that compatibility rather than a new feature. It's also the setting people reach for immediately after fontSize: we added runtime font-size controls, went to add line spacing beside them, and found it unavailable at any level.

Suggested shape

Matching xterm.js so existing code ports unchanged:

interface ITerminalOptions {
  lineHeight?: number;   // multiplier of measured line height, default 1.0
}

Feeding the same expression — roughly height = Math.ceil((ascent + descent) * lineHeight) + 2 — with the baseline offset by half the added leading so glyphs stay centred in the taller cell (xterm.js does this), and picked up by remeasureFont() so it works as a runtime option change like fontSize already does.

Relationship to open issues

This touches the same function as several open issues and should be built on whatever they settle rather than in parallel:

  • #207 — Math.ceil → Math.round on the cell width
  • #146 — rounding metrics to device-pixel boundaries, including the height expression
  • #126 — the visible gap between ── box-drawing cells; the hardcoded + 2 vertical leading looks like part of that story, and anything that changes it interacts with a lineHeight multiplier
Environment
  • ghostty-web 0.4.0-next.21.g640db46 (npm next, published 2026-10-28,
    commit 640db46), and 0.4.0 (npm latest) — ITerminalOptions and
    CanvasRenderer.measureFont() are identical in both, and lineHeight
    appears in neither the typings nor the bundle.
  • Canvas renderer, FitAddon, Vite + TypeScript
Lenguaje dominante
TypeScript
Estrellas
3.1k
Forks
202
Merge medio
1 d 40 min
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de coder/ghostty-web

Todos los issues de coder/ghostty-web

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.