From d3bc4ec07349a96c3863ddce63c2e52b5e7e9f2f Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 11 Oct 2020 22:38:30 +0200 Subject: =?UTF-8?q?Refactor=20layouting=20base=20=F0=9F=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/text.rs | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/layout/text.rs') 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, + /// The font variant, pub variant: FontVariant, + /// How to align this text node in its parent. pub aligns: Gen, } #[async_trait(?Send)] impl Layout for Text { - async fn layout( - &self, - ctx: &mut LayoutContext, - _constraints: LayoutConstraints, - ) -> Vec { + async fn layout(&self, ctx: &mut LayoutContext, _: &Areas) -> Vec { 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, + )] } } -- cgit v1.2.3