summaryrefslogtreecommitdiff
path: root/src/layout/text.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-10-11 22:38:30 +0200
committerLaurenz <laurmaedje@gmail.com>2020-10-11 22:38:30 +0200
commitd3bc4ec07349a96c3863ddce63c2e52b5e7e9f2f (patch)
tree09c582973b58f05f9248d88f0020bf1dda262aa5 /src/layout/text.rs
parentf04ad0ffa5f34bb7fd97e5c94c7547f96904220c (diff)
Refactor layouting base 🪁
Diffstat (limited to 'src/layout/text.rs')
-rw-r--r--src/layout/text.rs36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/layout/text.rs b/src/layout/text.rs
index 1c09b40a..7d8386a1 100644
--- a/src/layout/text.rs
+++ b/src/layout/text.rs
@@ -9,32 +9,36 @@ use crate::shaping;
/// A text node.
#[derive(Clone, PartialEq)]
pub struct Text {
+ /// The text.
pub text: String,
- pub size: Length,
+ /// The font size.
+ pub font_size: Length,
+ /// The text direction.
pub dir: Dir,
+ /// The families used for font fallback.
pub families: Rc<FallbackTree>,
+ /// The font variant,
pub variant: FontVariant,
+ /// How to align this text node in its parent.
pub aligns: Gen<Align>,
}
#[async_trait(?Send)]
impl Layout for Text {
- async fn layout(
- &self,
- ctx: &mut LayoutContext,
- _constraints: LayoutConstraints,
- ) -> Vec<Layouted> {
+ async fn layout(&self, ctx: &mut LayoutContext, _: &Areas) -> Vec<Layouted> {
let mut loader = ctx.loader.borrow_mut();
- let boxed = shaping::shape(
- &self.text,
- self.size,
- self.dir,
- &mut loader,
- &self.families,
- self.variant,
- )
- .await;
- vec![Layouted::Box(boxed, self.aligns)]
+ vec![Layouted::Boxed(
+ shaping::shape(
+ &mut loader,
+ &self.text,
+ self.font_size,
+ self.dir,
+ &self.families,
+ self.variant,
+ )
+ .await,
+ self.aligns,
+ )]
}
}