From 73615f7e3ce23f2ea656d04ea9f96184f5ebdc0a Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 24 Mar 2021 17:12:34 +0100 Subject: =?UTF-8?q?Text=20shaping=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Shapes text with rustybuzz - Font fallback with family list - Tofus are shown in the first font Co-Authored-By: Martin --- src/layout/text.rs | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) (limited to 'src/layout/text.rs') 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, - /// 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) } } -- cgit v1.2.3