diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-12-02 14:48:12 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-12-02 14:48:12 +0100 |
| commit | bfa9962632dd3c2e9110f9c3667d7e3cf6b133d4 (patch) | |
| tree | c48de05a4ae1e5c97eb4f6ddc9ede32ee65cf3ef /src/library/par.rs | |
| parent | f3bdc9d3daca2c26c4cc745be48a5ce1c8a10641 (diff) | |
Remove baseline weirdness
Diffstat (limited to 'src/library/par.rs')
| -rw-r--r-- | src/library/par.rs | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/library/par.rs b/src/library/par.rs index c29e5f9e..6abfa7af 100644 --- a/src/library/par.rs +++ b/src/library/par.rs @@ -466,14 +466,18 @@ impl<'a> LineLayout<'a> { // Measure the size of the line. for item in first.iter().chain(items).chain(&last) { - match *item { - ParItem::Absolute(v) => width += v, - ParItem::Fractional(v) => fr += v, - ParItem::Text(ShapedText { size, baseline, .. }) - | ParItem::Frame(Frame { size, baseline, .. }) => { - width += size.x; - top.set_max(baseline); - bottom.set_max(size.y - baseline); + match item { + ParItem::Absolute(v) => width += *v, + ParItem::Fractional(v) => fr += *v, + ParItem::Text(shaped) => { + width += shaped.size.x; + top.set_max(shaped.baseline); + bottom.set_max(shaped.size.y - shaped.baseline); + } + ParItem::Frame(frame) => { + width += frame.size.x; + top.set_max(frame.baseline()); + bottom.set_max(frame.size.y - frame.baseline()); } } } @@ -496,9 +500,9 @@ impl<'a> LineLayout<'a> { let size = Size::new(self.size.x.max(width), self.size.y); let remaining = size.x - self.size.x; - let mut output = Frame::new(size); let mut offset = Length::zero(); - output.baseline = self.baseline; + let mut output = Frame::new(size); + output.baseline = Some(self.baseline); for (range, item) in self.reordered() { let mut position = |mut frame: Frame| { @@ -510,7 +514,7 @@ impl<'a> LineLayout<'a> { } let x = offset + self.par.align.resolve(remaining); - let y = self.baseline - frame.baseline; + let y = self.baseline - frame.baseline(); offset += frame.size.x; // Add to the line's frame. @@ -633,17 +637,10 @@ impl<'a> LineStack<'a> { let mut output = Frame::new(self.size); let mut offset = Length::zero(); - let mut first = true; for line in self.lines.drain(..) { let frame = line.build(ctx, self.size.x); - let pos = Point::with_y(offset); - if first { - output.baseline = pos.y + frame.baseline; - first = false; - } - offset += frame.size.y + self.leading; output.merge_frame(pos, frame); } |
