summaryrefslogtreecommitdiff
path: root/src/layout/text.rs
diff options
context:
space:
mode:
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,
+ )]
}
}