Scale box-drawing characters vertically to fill line height

Box-drawing characters (│┃║┌┐└┘├┤etc) are designed to connect between
lines but the font's em-box is smaller than our line-height (14px vs
16.8px), creating visible gaps.

Solution: Render box-drawing characters as separate text elements with
a vertical scale transform of 1.2 (matching line-height) to stretch
them to fill the full cell height and connect properly.

This fixes disconnected vertical lines and corners in TUI applications.
This commit is contained in:
GitHub Copilot
2026-01-24 20:11:46 +00:00
parent 3701a3df31
commit ba23994c68
4 changed files with 50 additions and 2 deletions
+16
View File
@@ -328,6 +328,22 @@ class TestRenderTerminalSvg:
# Text tspan with yellow
assert f'fill="{ANSI_COLORS["yellow"]}"' in svg
def test_box_drawing_vertical_scale(self) -> None:
"""Box-drawing characters are scaled vertically to fill line height."""
buffer = [[self._char("")]] # Vertical line
svg = render_terminal_svg(buffer, width=80, height=24)
# Box drawing chars rendered with transform for vertical scaling
assert 'scale(1,1.2)' in svg
# Should be a separate text element, not a tspan
assert '<text x="' in svg
def test_box_drawing_corners(self) -> None:
"""Box-drawing corner characters are scaled."""
buffer = [[self._char(""), self._char("")]]
svg = render_terminal_svg(buffer, width=80, height=24)
# Both corners should have scale transforms
assert svg.count('scale(1,1.2)') == 2
def test_unicode_text(self) -> None:
"""Unicode text is preserved."""
buffer = self._make_buffer(["你好世界"])