diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-03-24 21:48:25 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-03-24 21:48:25 +0100 |
| commit | e8057a53856dc09594c9e5861f1cd328531616e0 (patch) | |
| tree | 36d7ffe8dc0aee0ab2ab96b37c130a8835f48f06 /src/layout | |
| parent | 73615f7e3ce23f2ea656d04ea9f96184f5ebdc0a (diff) | |
Make pdf module top-level 🧱
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/shaping.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/layout/shaping.rs b/src/layout/shaping.rs index f7eece92..8d035516 100644 --- a/src/layout/shaping.rs +++ b/src/layout/shaping.rs @@ -5,12 +5,12 @@ use ttf_parser::GlyphId; use super::{Element, Frame, ShapedText}; use crate::env::FontLoader; use crate::exec::FontProps; -use crate::geom::{Length, Point, Size}; +use crate::geom::{Point, Size}; -/// Shape text into a frame containing shaped [`ShapedText`] runs. +/// Shape text into a frame containing [`ShapedText`] runs. pub fn shape(text: &str, loader: &mut FontLoader, props: &FontProps) -> Frame { - let mut frame = Frame::new(Size::new(Length::ZERO, Length::ZERO)); - shape_segment(&mut frame, text, props.families.iter(), None, loader, props); + let mut frame = Frame::new(Size::ZERO); + shape_segment(&mut frame, text, loader, props, props.families.iter(), None); frame } @@ -18,10 +18,10 @@ pub fn shape(text: &str, loader: &mut FontLoader, props: &FontProps) -> Frame { fn shape_segment<'a>( frame: &mut Frame, text: &str, - mut families: impl Iterator<Item = &'a str> + Clone, - mut first: Option<FaceId>, loader: &mut FontLoader, props: &FontProps, + mut families: impl Iterator<Item = &'a str> + Clone, + mut first: Option<FaceId>, ) { // Select the font family. let (id, fallback) = loop { @@ -41,12 +41,12 @@ fn shape_segment<'a>( }; // Register that this is the first available font. - let face = loader.face(id); if first.is_none() { first = Some(id); } // Find out some metrics and prepare the shaped text container. + let face = loader.face(id); let ttf = face.ttf(); let units_per_em = f64::from(ttf.units_per_em().unwrap_or(1000)); let convert = |units| f64::from(units) / units_per_em * props.size; @@ -104,7 +104,7 @@ fn shape_segment<'a>( let range = start .. end + offset; // Recursively shape the tofu sequence with the next family. - shape_segment(frame, &text[range], families.clone(), first, loader, props); + shape_segment(frame, &text[range], loader, props, families.clone(), first); } else { // Add the glyph to the shaped output. // TODO: Don't ignore y_advance and y_offset. |
