diff options
| author | Laurenz Mädje <laurmaedje@gmail.com> | 2019-06-02 18:01:22 +0200 |
|---|---|---|
| committer | Laurenz Mädje <laurmaedje@gmail.com> | 2019-06-02 18:01:22 +0200 |
| commit | 221934df4b586250b0063282ef8885c475dec7a7 (patch) | |
| tree | ea91eb6fe6fbad71377f2dbf1c23a3a808dbf970 /src/layout/text.rs | |
| parent | c4eb4ee36261be8832b2649cc075edee188be5c7 (diff) | |
Add margins with basic box layouter 📖
Diffstat (limited to 'src/layout/text.rs')
| -rw-r--r-- | src/layout/text.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/layout/text.rs b/src/layout/text.rs index 15da8373..0f105531 100644 --- a/src/layout/text.rs +++ b/src/layout/text.rs @@ -7,7 +7,7 @@ use smallvec::SmallVec; use crate::doc::TextAction; use crate::font::{Font, FontQuery}; -use super::{Layouter, Layout, LayoutError, LayoutContext, Size, LayoutResult}; +use super::{Layouter, Layout, LayoutError, LayoutContext, LayoutResult, Size, Position}; /// Layouts text within the constraints of a layouting context. @@ -208,10 +208,11 @@ impl<'a, 'p> TextFinisher<'a, 'p> { /// Move to the top-left corner of the layout space. fn move_start(&mut self) { - self.actions.push(TextAction::MoveNewline( - Size::zero(), self.layouter.ctx.max_extent.height + self.actions.push(TextAction::MoveNewline(Position { + x: Size::zero(), + y: self.layouter.ctx.max_extent.height - Size::from_points(self.layouter.ctx.text_style.font_size) - )); + })); } /// Move to the next line. A factor of 1.0 uses the default line spacing. @@ -221,7 +222,11 @@ impl<'a, 'p> TextFinisher<'a, 'p> { * self.layouter.ctx.text_style.line_spacing * factor; - self.actions.push(TextAction::MoveNewline(Size::zero(), -vertical)); + self.actions.push(TextAction::MoveNewline(Position { + x: Size::zero(), + y: -vertical + })); + self.current_width = Size::zero(); } } |
