Use active font metrics for grid line rendering #9606

Open
opened 2026-01-31 01:59:03 +00:00 by claunia · 0 comments
Owner

Originally created by @j4james on GitHub (Jul 14, 2020).

Description of the new feature/enhancement

I was looking at adding support for the crossed-out attribute, but found that it doesn't look very good without getting the font metrics to draw the line in the right position, and ideally the right size. And I know there have also been discussions before about the need to draw the underline in the right position and size.

So as a first step, I thought it might be good idea to put together a PR just gathering the font line metrics, and updating the grid line code to take those metrics into account. This is not about drawing the underline in the right position yet - just getting the existing grid lines to scale with the font size.

Proposed technical implementation details (optional)

My first thought was to use the underline thickness metric for the width of all grid lines, and you can see an example of what that might look like below:

image

But based on those results, I'm now more inclined to think a hard coded size might be preferable. Either option would be better than the current single pixel width, though, which is almost invisible on high dpi displays. If we do go with a hard coded value, I think something around the thickness of Cascadia or Fira Code would be reasonable (that's about 0.025em).

And while looking at this area of the code, I also wanted to propose some refactoring of the grid line renderer to be more efficient. In the current implementation, if you're drawing an underline across 20 cells, it actually renders it with 20 separate strokes, when it could easily be done in one. The left and right grid lines still need to be rendered one cell at a time, but that's a much less common occurrence.

So just to summarize:

  1. Is is OK if I do a PR to make the grid lines scale with the font size?
  2. If so, should I use the font's underline thickness or a fixed em size?
  3. Can I do a refactor/optimisation of the rendering code at the same time?
Originally created by @j4james on GitHub (Jul 14, 2020). # Description of the new feature/enhancement I was looking at adding support for the _crossed-out_ attribute, but found that it doesn't look very good without getting the font metrics to draw the line in the right position, and ideally the right size. And I know there have also been discussions before about the need to draw the underline in the right position and size. So as a first step, I thought it might be good idea to put together a PR just gathering the font line metrics, and updating the grid line code to take those metrics into account. This is not about drawing the underline in the right position yet - just getting the existing grid lines to scale with the font size. # Proposed technical implementation details (optional) My first thought was to use the underline thickness metric for the width of all grid lines, and you can see an example of what that might look like below: ![image](https://user-images.githubusercontent.com/4181424/87459007-b6f58780-c602-11ea-98b8-edf53e01dd71.png) But based on those results, I'm now more inclined to think a hard coded size might be preferable. Either option would be better than the current single pixel width, though, which is almost invisible on high dpi displays. If we do go with a hard coded value, I think something around the thickness of _Cascadia_ or _Fira Code_ would be reasonable (that's about 0.025em). And while looking at this area of the code, I also wanted to propose some refactoring of the grid line renderer to be more efficient. In the current implementation, if you're drawing an underline across 20 cells, it actually renders it with 20 separate strokes, when it could easily be done in one. The left and right grid lines still need to be rendered one cell at a time, but that's a much less common occurrence. So just to summarize: 1. Is is OK if I do a PR to make the grid lines scale with the font size? 2. If so, should I use the font's underline thickness or a fixed em size? 3. Can I do a refactor/optimisation of the rendering code at the same time?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9606