mirror of
https://github.com/typst/typst
synced 2025-07-27 22:37:54 +08:00
Don't label empty orphan frames
Adding a label makes a previously empty frame non-empty, but we want to keep orphans empty.
This commit is contained in:
parent
693edb475d
commit
02f07e7912
@ -204,13 +204,11 @@ pub fn layout_multi_block(
|
|||||||
let has_inset = !inset.is_zero();
|
let has_inset = !inset.is_zero();
|
||||||
let is_explicit = matches!(body, None | Some(BlockBody::Content(_)));
|
let is_explicit = matches!(body, None | Some(BlockBody::Content(_)));
|
||||||
|
|
||||||
// Skip filling/stroking the first frame if it is empty and a non-empty
|
// Skip filling, stroking and labeling the first frame if it is empty and
|
||||||
// one follows.
|
// a non-empty one follows.
|
||||||
let mut skip_first = false;
|
let mut skip_first = false;
|
||||||
if let [first, rest @ ..] = fragment.as_slice() {
|
if let [first, rest @ ..] = fragment.as_slice() {
|
||||||
skip_first = has_fill_or_stroke
|
skip_first = first.is_empty() && rest.iter().any(|frame| !frame.is_empty());
|
||||||
&& first.is_empty()
|
|
||||||
&& rest.iter().any(|frame| !frame.is_empty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post-process to apply insets, clipping, fills, and strokes.
|
// Post-process to apply insets, clipping, fills, and strokes.
|
||||||
@ -242,7 +240,8 @@ pub fn layout_multi_block(
|
|||||||
|
|
||||||
// Assign label to each frame in the fragment.
|
// Assign label to each frame in the fragment.
|
||||||
if let Some(label) = elem.label() {
|
if let Some(label) = elem.label() {
|
||||||
for frame in fragment.iter_mut() {
|
// Skip empty orphan frames, as a label would make them non-empty.
|
||||||
|
for frame in fragment.iter_mut().skip(if skip_first { 1 } else { 0 }) {
|
||||||
frame.label(label);
|
frame.label(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 312 B |
Loading…
x
Reference in New Issue
Block a user