diff options
Diffstat (limited to 'src/layout/text.rs')
| -rw-r--r-- | src/layout/text.rs | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/src/layout/text.rs b/src/layout/text.rs index 2239afac..39866907 100644 --- a/src/layout/text.rs +++ b/src/layout/text.rs @@ -1,50 +1,25 @@ use std::fmt::{self, Debug, Formatter}; -use std::rc::Rc; - -use fontdock::FontVariant; use super::*; -use crate::exec::FamilyMap; +use crate::exec::FontProps; /// A consecutive, styled run of text. #[derive(Clone, PartialEq)] pub struct TextNode { - /// The text. - pub text: String, /// The text direction. pub dir: Dir, /// How to align this text node in its parent. pub aligns: LayoutAligns, - /// The list of font families for shaping. - pub families: Rc<FamilyMap>, - /// The font variant, - pub variant: FontVariant, - /// The font size. - pub font_size: Length, - /// The top end of the text bounding box. - pub top_edge: VerticalFontMetric, - /// The bottom end of the text bounding box. - pub bottom_edge: VerticalFontMetric, - /// The glyph fill. - pub color: Fill, + /// The text. + pub text: String, + /// Properties used for font selection and layout. + pub props: FontProps, } impl Layout for TextNode { fn layout(&self, ctx: &mut LayoutContext, _: &Areas) -> Fragment { - Fragment::Frame( - shape( - &self.text, - self.dir, - &self.families, - self.variant, - self.font_size, - self.top_edge, - self.bottom_edge, - self.color, - &mut ctx.env.fonts, - ), - self.aligns, - ) + let frame = shape(&self.text, &mut ctx.env.fonts, &self.props); + Fragment::Frame(frame, self.aligns) } } |
