From 6ff60bc3688d8ae2caa3ea18bc23963d25ab5daa Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 22 Nov 2019 20:15:00 +0100 Subject: =?UTF-8?q?Fix=20secondary=20non-origin=20alignment=20=F0=9F=9A=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/tree.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/layout/tree.rs') diff --git a/src/layout/tree.rs b/src/layout/tree.rs index f6a8f408..f5ae2435 100644 --- a/src/layout/tree.rs +++ b/src/layout/tree.rs @@ -58,16 +58,19 @@ impl<'a, 'p> TreeLayouter<'a, 'p> { } fn layout_space(&mut self) { - self.flex.add_primary_space(word_spacing(&self.style), true); + self.flex.add_primary_space(word_spacing(&self.style), SpaceKind::Soft); } fn layout_paragraph(&mut self) -> LayoutResult<()> { - self.flex.add_secondary_space(paragraph_spacing(&self.style), true) + self.flex.add_secondary_space(paragraph_spacing(&self.style), SpaceKind::Soft) } fn layout_func(&mut self, func: &FuncCall) -> LayoutResult<()> { let (first, second) = self.flex.remaining()?; + let mut axes = self.ctx.axes.expanding(false); + axes.secondary.alignment = Alignment::Origin; + let ctx = |spaces| { LayoutContext { loader: self.ctx.loader, @@ -75,7 +78,7 @@ impl<'a, 'p> TreeLayouter<'a, 'p> { text_style: &self.style, page_style: self.ctx.page_style, spaces, - axes: self.ctx.axes.expanding(false), + axes, expand: false, } }; @@ -106,8 +109,10 @@ impl<'a, 'p> TreeLayouter<'a, 'p> { Command::Add(layout) => self.flex.add(layout), Command::AddMultiple(layouts) => self.flex.add_multiple(layouts), - Command::AddPrimarySpace(space) => self.flex.add_primary_space(space, false), - Command::AddSecondarySpace(space) => self.flex.add_secondary_space(space, false)?, + Command::AddPrimarySpace(space) + => self.flex.add_primary_space(space, SpaceKind::Hard), + Command::AddSecondarySpace(space) + => self.flex.add_secondary_space(space, SpaceKind::Hard)?, Command::FinishLine => self.flex.add_break(), Command::FinishRun => { self.flex.finish_run()?; }, -- cgit v1.2.3