Add option for box-drawing characters to scale with font zoom
- Dominant language
- Python
- Stars
- 34.9k
- Forks
- 1.5k
- Avg merge
- 8h 28m
- Merged PRs (30d)
- 43
Description
**Is your feature request related to a problem? Please describe.**
Box drawing characters such as
```
╭─
╰─
```
scale in a way that disregards the font size/zoom. That leads to oddities where the box-drawing characters can appear thin in high zoom, or thick in low zoom, depending on what you have the characters set to in your kitty.conf.
**Describe the solution you'd like**
Add an option to scale box-drawing characters like how text is normally scaled, e.g. `box_drawing_scale_with_font`.
**Describe alternatives you've considered**
```diff
This is my temporary patch workaround (0.48.2) but it's certainly too dirty (hardcoded constants, etc.)
I might get around to a better version once I figure out how to add the rest of the options
stuff/docs to make it cleaner.
--- a/kitty/fonts.c
+++ b/kitty/fonts.c
@@ -1069,7 +1069,11 @@ render_box_cell(FontGroup *fg, RunFont rf, CPUCell *cpu_cell, GPUCell *gpu_cell,
return;
}
FontCellMetrics unscaled_metrics = fg->fcm;
+ // apply_scale_to_font_group() overwrites fg->font_sz_in_pts with scaled size
+ const double base_font_size = fg->font_sz_in_pts;
float scale = apply_scale_to_font_group(fg, &rf);
+ // 11.0 is the default font size
+ const double box_scale = scale * base_font_size / 11.0;
ensure_canvas_can_fit(fg, num_glyphs + 1, rf.scale);
FontCellMetrics scaled_metrics = fg->fcm;
if (scale != 1) apply_scale_to_font_group(fg, NULL);
@@ -1087,7 +1091,7 @@ render_box_cell(FontGroup *fg, RunFont rf, CPUCell *cpu_cell, GPUCell *gpu_cell,
for (unsigned i = 0, cnum = 0; i < num_glyphs; i++) {
unsigned int ch = global_glyph_render_scratch.lc->chars[cnum++];
while (!ch) ch = global_glyph_render_scratch.lc->chars[cnum++];
- render_box_char(ch, fg->canvas.alpha_mask, src.right, src.bottom, fg->logical_dpi_x, fg->logical_dpi_y, scale);
+ render_box_char(ch, fg->canvas.alpha_mask, src.right, src.bottom, fg->logical_dpi_x, fg->logical_dpi_y, box_scale);
dest.left = i * scaled_metrics.cell_width + right_shift; dest.right = dest.left + scaled_metrics.cell_width;
render_alpha_mask(fg->canvas.alpha_mask, fg->canvas.buf, &src, &dest, src.right, mask_stride, 0xffffff);
}
```
**Additional context**
Example on foot:
Example on kitty:
(The screenshot doesn't do it justice, but kitty box-drawing characters can appear pretty thin in high zoom due to this issue.)
Contributor guide
Research direction
Start in kitty/fonts.c at render_box_cell and compare the existing apply_scale_to_font_group flow with the proposed box_scale calculation. Trace how the new option would connect to the existing option and documentation machinery, then verify that box-drawing characters scale with font zoom without changing the normal rendering path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- cli, desktop
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100