summaryrefslogtreecommitdiff
path: root/src/layout/text.rs
diff options
context:
space:
mode:
authorLaurenz Mädje <laurmaedje@gmail.com>2019-06-02 18:01:22 +0200
committerLaurenz Mädje <laurmaedje@gmail.com>2019-06-02 18:01:22 +0200
commit221934df4b586250b0063282ef8885c475dec7a7 (patch)
treeea91eb6fe6fbad71377f2dbf1c23a3a808dbf970 /src/layout/text.rs
parentc4eb4ee36261be8832b2649cc075edee188be5c7 (diff)
Add margins with basic box layouter 📖
Diffstat (limited to 'src/layout/text.rs')
-rw-r--r--src/layout/text.rs15
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();
}
}