mirror of
https://github.com/typst/typst
synced 2025-07-15 16:42:53 +08:00
skip layout of redundant gutter at the top of footer
This commit is contained in:
parent
315612b1f7
commit
d13617ed9b
@ -232,7 +232,7 @@ pub(super) enum Row {
|
|||||||
|
|
||||||
impl Row {
|
impl Row {
|
||||||
/// Returns the `y` index of this row.
|
/// Returns the `y` index of this row.
|
||||||
fn index(&self) -> usize {
|
pub(super) fn index(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Self::Frame(_, y, _) => *y,
|
Self::Frame(_, y, _) => *y,
|
||||||
Self::Fr(_, y, _) => *y,
|
Self::Fr(_, y, _) => *y,
|
||||||
|
@ -679,9 +679,23 @@ impl<'a> GridLayouter<'a> {
|
|||||||
let footer_len = footer.range.end - footer.range.start;
|
let footer_len = footer.range.end - footer.range.start;
|
||||||
self.unbreakable_rows_left += footer_len;
|
self.unbreakable_rows_left += footer_len;
|
||||||
|
|
||||||
// TODO(subfooters): also consider omitted gutter before the footer
|
let footer_start = if self.grid.is_gutter_track(footer.range.start)
|
||||||
// when there is a header right before it taking it.
|
&& self
|
||||||
for y in footer.range.clone() {
|
.current
|
||||||
|
.lrows
|
||||||
|
.last()
|
||||||
|
.is_none_or(|r| self.grid.is_gutter_track(r.index()))
|
||||||
|
{
|
||||||
|
// Skip gutter at the top of footer if there's already a gutter
|
||||||
|
// from a repeated header right before it in the current region.
|
||||||
|
// Normally, that shouldn't happen as it indicates we have a widow,
|
||||||
|
// but we can't fully prevent widows anyway.
|
||||||
|
footer.range.start + 1
|
||||||
|
} else {
|
||||||
|
footer.range.start
|
||||||
|
};
|
||||||
|
|
||||||
|
for y in footer_start..footer.range.end {
|
||||||
self.layout_row_with_state(
|
self.layout_row_with_state(
|
||||||
y,
|
y,
|
||||||
engine,
|
engine,
|
||||||
|
BIN
tests/ref/grid-footer-gutter-short-lived.png
Normal file
BIN
tests/ref/grid-footer-gutter-short-lived.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 321 B |
@ -41,6 +41,20 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
--- grid-footer-gutter-short-lived ---
|
||||||
|
// Gutter, no repetition, short-lived
|
||||||
|
#set page(height: 6em)
|
||||||
|
#set text(6pt)
|
||||||
|
#set table(inset: 2pt, stroke: 0.5pt)
|
||||||
|
#table(
|
||||||
|
gutter: 2pt,
|
||||||
|
align: center + horizon,
|
||||||
|
table.header([a]),
|
||||||
|
table.footer([b]),
|
||||||
|
table.footer([c]),
|
||||||
|
[d],
|
||||||
|
)
|
||||||
|
|
||||||
--- grid-cell-override-in-header-and-footer ---
|
--- grid-cell-override-in-header-and-footer ---
|
||||||
#table(
|
#table(
|
||||||
table.header(table.cell(stroke: red)[Hello]),
|
table.header(table.cell(stroke: red)[Hello]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user