use anyhow::Result; use harfrust::{Direction, Feature, Script, ShaperData, Tag, UnicodeBuffer}; use icu_properties::{CodePointMapData, props::Script as IcuScript}; use skrifa::raw::TableProvider; use crate::font::Font; /// A glyph with positioning information. /// clone of harfrust::PositionedGlyph with glyph_id and cluster #[derive(Debug, Clone)] pub struct PositionedGlyph<'a> { /// The glyph ID as per the font's glyph set. pub glyph_id: u32, /// The cluster index in the original text that this glyph corresponds to. pub cluster: u32, /// Font used to shape this glyph. pub font: &'a Font, /// How much the line advances after drawing this glyph when setting text in /// horizontal direction. pub x_advance: f32, /// How much the line advances after drawing this glyph when setting text in /// vertical direction. pub y_advance: f32, /// How much the glyph moves on the X-axis before drawing it, this should /// not affect how much the line advances. pub x_offset: f32, /// How much the glyph moves on the Y-axis before drawing it, this should /// not affect how much the line advances. pub y_offset: f32, } /// A shaped run of text, containing positioned glyphs and overall advance. #[derive(Debug, Clone)] pub struct ShapedRun<'a> { pub glyphs: Vec>, pub x_advance: f32, pub y_advance: f32, } /// Options for shaping text. #[derive(Debug, Clone)] pub struct ShapingOptions<'a> { pub direction: Direction, pub script: Option