From 2b54c4e86acd1c8686516e041ab5f0f8909cffac Mon Sep 17 00:00:00 2001 From: Tobias Schmitz Date: Tue, 6 May 2025 09:18:49 +0200 Subject: [PATCH] docs: update comments --- crates/typst-layout/src/grid/layouter.rs | 12 +++++++----- crates/typst-layout/src/grid/rowspans.rs | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/typst-layout/src/grid/layouter.rs b/crates/typst-layout/src/grid/layouter.rs index 093d48dd8..99b85eddb 100644 --- a/crates/typst-layout/src/grid/layouter.rs +++ b/crates/typst-layout/src/grid/layouter.rs @@ -645,8 +645,9 @@ impl<'a> GridLayouter<'a> { let width = self.cell_spanned_width(cell, x); let mut pos = Point::new(dx, dy); if self.is_rtl { - // In RTL cells expand to the left, thus the position - // must additionally be offset by the width of the cell. + // In RTL cells expand to the left, thus the + // position must additionally be offset by the + // cell's width. pos.x = self.width - (dx + width); } let size = Size::new(width, height); @@ -1253,7 +1254,7 @@ impl<'a> GridLayouter<'a> { let mut pos = offset; if self.is_rtl { // In RTL cells expand to the left, thus the position - // must additionally be offset by the width of the cell. + // must additionally be offset by the cell's width. pos.x = self.width - (pos.x + width); } output.push_frame(pos, frame); @@ -1301,8 +1302,9 @@ impl<'a> GridLayouter<'a> { for (output, frame) in outputs.iter_mut().zip(fragment) { let mut pos = offset; if self.is_rtl { - // In RTL cells expand to the left, thus the position - // must additionally be offset by the width of the cell. + // In RTL cells expand to the left, thus the + // position must additionally be offset by the + // cell's width. pos.x = self.width - (offset.x + width); } output.push_frame(pos, frame); diff --git a/crates/typst-layout/src/grid/rowspans.rs b/crates/typst-layout/src/grid/rowspans.rs index 456ddc8f5..5ab0417d8 100644 --- a/crates/typst-layout/src/grid/rowspans.rs +++ b/crates/typst-layout/src/grid/rowspans.rs @@ -123,6 +123,8 @@ impl GridLayouter<'_> { }; let cell = self.grid.cell(x, y).unwrap(); let width = self.cell_spanned_width(cell, x); + // In RTL cells expand to the left, thus the position + // must additionally be offset by the cell's width. let dx = if self.is_rtl { self.width - (dx + width) } else { dx }; // Prepare regions.