From b471cb7d3ce8d07be25c1673b277072fe123dd12 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sun, 19 Jul 2026 08:46:29 +0000 Subject: [PATCH 07/71] fix(macos): give the render probe a page margin so column 0 is not clipped The first column's glyph bearing extended left of x=0 with a zero page margin, clipping the leading character ("contour" rendered as "ontour"). Enlarge the surface by a 2px margin on each side and pass a matching PageMargin via applyResize so cell (0,0) maps inside the surface. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01AeG2jwYMX5gdvvtUnx3PJa --- src/contour_macos/render_probe.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/contour_macos/render_probe.cpp b/src/contour_macos/render_probe.cpp index 9c7b69a4..2f78a45a 100644 --- a/src/contour_macos/render_probe.cpp +++ b/src/contour_macos/render_probe.cpp @@ -118,8 +118,12 @@ int main(int argc, char** argv) Decorator::CurlyUnderline }; auto const cellSize = renderer.gridMetrics().cellSize; - auto const pixelWidth = Width::cast_from(unbox(cellSize.width) * unbox(pageSize.columns)); - auto const pixelHeight = Height::cast_from(unbox(cellSize.height) * unbox(pageSize.lines)); + // A small page margin so the first column's glyph bearing is not clipped at the left edge. + int const margin = 2; + auto const pixelWidth = + Width::cast_from(unbox(cellSize.width) * unbox(pageSize.columns) + 2 * margin); + auto const pixelHeight = + Height::cast_from(unbox(cellSize.height) * unbox(pageSize.lines) + 2 * margin); auto const surfaceSize = ImageSize { pixelWidth, pixelHeight }; auto target = contour_macos::SoftwareRenderTarget { surfaceSize }; @@ -127,6 +131,7 @@ int main(int argc, char** argv) (void) renderer.applyStagedReconfigDuringSetup(); target.setRenderSize(surfaceSize); + renderer.applyResize(surfaceSize, pageSize, vtrasterizer::PageMargin { margin, margin, margin }); target.beginFrame(); (void) renderer.render(terminal, /* pressureHint */ false);