Skip to content

Additional options for lineHeight option (fractional height, pixel height) #4463

Open
@sholalkere

Description

(Note, all screenshots were taken with webgl enabled.)
Some, fonts, e.g. Comic Code, appear to have too large of a line height even with lineHeight = 1.

line height is visibly larger than font height

Fractional line heights would allow for what I believe is a more reasonable spacing in between lines.
image

I think there should be support for for fractional line heights, and line heights specified in pixels (as suggested in #2612).

My proposal is to follow VSCode's convention for handling lineHeight (with some modifications).
VSCode's policy for line height

First, instead of allowing lineHeight = 0, the user can just use lineHeight = 1, which already computes the line height from the character height.
Next, if 0 < lineHeight <= 8, the line height can be treated as a multiplier for the character height (as it is currently).
Finally, if lineHeight > 8 the line height is exactly what is specified (in pixels).

These fixes can be implemented relatively quickly with something like the following in CanvasRenderer.ts and WebglRenderer.ts (and of course modifying the allowed bounds in OptionsService.ts).
this.dimensions.device.cell.height = this._optionsService.rawOptions.lineHeight > 8 ? this._optionsService.rawOptions.lineHeight : Math.floor(this.dimensions.device.char.height * this._optionsService.rawOptions.lineHeight);

One potential downside is that characters can potentially be too large for the cell and are thus cut off, but I believe this behavior is fine if one is willing to stray from within the multiplier bounds (and I'm not sure how many users uselineHeight as a multiplier for something greater than 8 so effectively no functionality is lost). Furthermore, the way VSCode handles this, for example, is allowing characters to overlap, which I believe leads to a similar loss in clarity.
cut off characters when line height is too small

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions