Skip to content

feat: support 'px' format in lineHeight option#5730

Open
evandroreichert wants to merge 1 commit intoxtermjs:masterfrom
evandroreichert:feat/lineheight-px-support
Open

feat: support 'px' format in lineHeight option#5730
evandroreichert wants to merge 1 commit intoxtermjs:masterfrom
evandroreichert:feat/lineheight-px-support

Conversation

@evandroreichert
Copy link
Copy Markdown

Summary

Closes #2612

Allow lineHeight to accept a string with a 'px' suffix (e.g. '23px') in addition to the existing numeric multiplier, enabling precise pixel-level control over row spacing.

Changes

  • Type definitions (xterm.d.ts, Services.ts): lineHeight now accepts number | string
  • Validation (OptionsService.ts): String values must end with 'px' and parse to a number >= 1
  • DomRenderer & WebglRenderer: When a px string is provided, the cell height is computed as Math.max(Math.floor(parseFloat(lineHeight) * dpr), charHeight) instead of the multiplier-based calculation
  • WebGL types (Types.ts): Updated ICharAtlasConfig.lineHeight to match

Backwards compatibility

Fully backwards compatible — existing numeric lineHeight values behave identically. The new string format is opt-in.

Example usage

// Existing multiplier (unchanged)
terminal.options.lineHeight = 1.2;

// New: absolute pixel height
terminal.options.lineHeight = '23px';

Allow lineHeight to accept a string with 'px' suffix (e.g. '23px') in
addition to the existing numeric multiplier. This enables setting an
absolute pixel line height, which is useful when precise control over
row spacing is needed regardless of font size.

- Update type definitions to accept `number | string`
- Add validation for px string format in OptionsService
- Handle px values in DomRenderer and WebglRenderer dimension calculations
- Update WebGL char atlas config type

Fixes xtermjs#2612
@evandroreichert evandroreichert force-pushed the feat/lineheight-px-support branch from b5b8d10 to e4159ac Compare March 2, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support 'px' format in lineHeight option

1 participant