From 2c6127dea611944abb09a0d38375ad7cf9baced0 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 29 Jul 2021 13:21:25 +0200 Subject: Refactor state --- src/layout/par.rs | 4 ++-- src/layout/shaping.rs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/layout') diff --git a/src/layout/par.rs b/src/layout/par.rs index 03d7efd5..a88a0f0b 100644 --- a/src/layout/par.rs +++ b/src/layout/par.rs @@ -5,7 +5,7 @@ use unicode_bidi::{BidiInfo, Level}; use xi_unicode::LineBreakIterator; use super::*; -use crate::exec::TextState; +use crate::exec::FontState; use crate::util::{EcoString, RangeExt, SliceExt}; type Range = std::ops::Range; @@ -29,7 +29,7 @@ pub enum ParChild { /// Spacing between other nodes. Spacing(Length), /// A run of text and how to align it in its line. - Text(EcoString, Align, Rc), + Text(EcoString, Align, Rc), /// Any child node and how to align it in its line. Any(LayoutNode, Align), } diff --git a/src/layout/shaping.rs b/src/layout/shaping.rs index 0cfb01a8..3ede5122 100644 --- a/src/layout/shaping.rs +++ b/src/layout/shaping.rs @@ -5,7 +5,7 @@ use std::ops::Range; use rustybuzz::UnicodeBuffer; use super::{Element, Frame, Glyph, LayoutContext, Text}; -use crate::exec::{LineState, TextState}; +use crate::exec::{FontState, LineState}; use crate::font::{Face, FaceId, FontVariant, LineMetrics}; use crate::geom::{Dir, Length, Point, Size}; use crate::layout::Geometry; @@ -23,7 +23,7 @@ pub struct ShapedText<'a> { /// The text direction. pub dir: Dir, /// The properties used for font selection. - pub state: &'a TextState, + pub state: &'a FontState, /// The font size. pub size: Size, /// The baseline from the top of the frame. @@ -185,7 +185,7 @@ pub fn shape<'a>( ctx: &mut LayoutContext, text: &'a str, dir: Dir, - state: &'a TextState, + state: &'a FontState, ) -> ShapedText<'a> { let mut glyphs = vec![]; if !text.is_empty() { @@ -346,7 +346,7 @@ fn shape_segment<'a>( fn measure( ctx: &mut LayoutContext, glyphs: &[ShapedGlyph], - state: &TextState, + state: &FontState, ) -> (Size, Length) { let mut width = Length::zero(); let mut top = Length::zero(); @@ -386,7 +386,7 @@ fn decorate( pos: Point, width: Length, face_id: FaceId, - state: &TextState, + state: &FontState, ) { let mut apply = |substate: &LineState, metrics: fn(&Face) -> &LineMetrics| { let metrics = metrics(ctx.fonts.get(face_id)); -- cgit v1.2.3