diff --git a/Cargo.lock b/Cargo.lock index 849ff51b24..3f2b77cdd4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1108,7 +1108,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=935dc0084680a3045b935ba303ab3ea08c38e1e7#935dc0084680a3045b935ba303ab3ea08c38e1e7" +source = "git+https://github.com/storytold/craft-libs?rev=54485a66ceb7a7b6eaa584deee5bb76a85ea310f#54485a66ceb7a7b6eaa584deee5bb76a85ea310f" dependencies = [ "kurbo 0.13.1", ] diff --git a/crates/text/Cargo.toml b/crates/text/Cargo.toml index af8538730c..42815fbc96 100644 --- a/crates/text/Cargo.toml +++ b/crates/text/Cargo.toml @@ -9,7 +9,7 @@ description = "VectorCraft text: font database, shaping, layout, glyph outlines" workspace = true [dependencies] -craft-text = { git = "https://github.com/storytold/craft-libs", rev = "935dc0084680a3045b935ba303ab3ea08c38e1e7", default-features = false, features = ["positioned"] } +craft-text = { git = "https://github.com/storytold/craft-libs", rev = "54485a66ceb7a7b6eaa584deee5bb76a85ea310f", default-features = false, features = ["positioned"] } vectorcraft-geom = { workspace = true } vectorcraft-doc = { workspace = true } kurbo = { workspace = true } diff --git a/crates/text/src/composer.rs b/crates/text/src/composer.rs index 79f0ffd5ca..269c57d3c2 100644 --- a/crates/text/src/composer.rs +++ b/crates/text/src/composer.rs @@ -1,6 +1,32 @@ //! Adapters from VectorCraft's shaped glyphs to the shared paragraph composer. -pub(crate) use craft_text::composer::{Breakpoint, Exhausted, Measure, Params, compose, compose_with}; +use crate::justify::Flex; +use crate::shape::SGlyph; +pub(crate) use craft_text::composer::{Breakpoint, Exhausted, Measure, Params}; + +pub(crate) fn compose( + g: &[SGlyph], + width: &dyn Fn(usize) -> f64, + start: &dyn Fn(usize) -> f64, + end: &dyn Fn(usize) -> f64, + cands: &[Breakpoint], + flex: &[Flex], + params: &Params, +) -> Option> { + craft_text::composer::compose(g, width, start, end, cands, flex, params) +} + +pub(crate) fn compose_with( + g: &[SGlyph], + measure: &mut M, + start: &dyn Fn(usize) -> f64, + end: &dyn Fn(usize) -> f64, + cands: &[Breakpoint], + flex: &[Flex], + params: &Params, +) -> Option> { + craft_text::composer::compose_with(g, measure, start, end, cands, flex, params) +} impl craft_text::composer::Glyph for crate::shape::SGlyph { fn advance(&self) -> f64 {