Merge branch 'codex/shared-font-outline-caller' into codex/shared-shaped-run-caller

# Conflicts:
#	Cargo.lock
#	crates/text/Cargo.toml
This commit is contained in:
Dylan M. Taylor
2026-11-15 16:29:26 +00:00
3 changed files with 35 additions and 2 deletions
Generated
+1 -1
View File
@@ -1008,7 +1008,7 @@ source = "git+https://github.com/storytold/craft-libs?rev=6d620e971e820b517b11a9
[[package]]
name = "craft-font-catalog"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=159b942defe3613c91a4beec5fadfcb1593f2600#159b942defe3613c91a4beec5fadfcb1593f2600"
source = "git+https://github.com/storytold/craft-libs?rev=11f54a35ff8a62f06b752c752c7ab5c991f4de7a#11f54a35ff8a62f06b752c752c7ab5c991f4de7a"
dependencies = [
"harfrust 0.13.3",
"kurbo 0.13.1",
+1 -1
View File
@@ -10,7 +10,7 @@ workspace = true
[dependencies]
# Pending shared extraction; pin the immutable official PR head until it merges.
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "159b942defe3613c91a4beec5fadfcb1593f2600", default-features = false }
craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "11f54a35ff8a62f06b752c752c7ab5c991f4de7a", default-features = false }
vectorcraft-geom = { workspace = true }
vectorcraft-doc = { workspace = true }
kurbo = { workspace = true }
+33
View File
@@ -657,4 +657,37 @@ mod shared_outline_tests {
assert_eq!(*db.outline(&face, glyph.to_u32()), old.0, "glyph {ch}");
}
}
#[test]
fn malformed_cff_prefix_matches_original_pen() {
use skrifa::raw::ps::cff::CffFontRef;
let Ok(dir) = std::env::var("CRAFT_FONTS_DIR") else { return };
let mut bytes = std::fs::read(std::path::Path::new(&dir).join("fonts/noto-sans-cjk-sc/NotoSansCJKsc-Regular.otf")).unwrap();
let (gid, start) = {
let f = skrifa::FontRef::new(&bytes).unwrap();
let table = f.table_data(skrifa::Tag::new(b"CFF ")).unwrap().as_bytes();
let cff = CffFontRef::new(table, 0, None).unwrap();
let (gid, cs) = (0..cff.num_glyphs())
.find_map(|gid| {
let cs = cff.charstrings().get(gid as usize)?;
(cs.len() >= 8).then_some((gid, cs))
})
.unwrap();
(gid, cs.as_ptr() as usize - bytes.as_ptr() as usize)
};
bytes[start..start + 8].copy_from_slice(&[139, 139, 21, 239, 139, 5, 10, 14]);
let f = skrifa::FontRef::new(&bytes).unwrap();
let mut old = FlipPen(BezPath::new());
let result = f
.outline_glyphs()
.get(GlyphId::new(gid))
.unwrap()
.draw(DrawSettings::unhinted(Size::unscaled(), skrifa::instance::LocationRef::default()), &mut old);
assert!(result.is_err());
assert!(!old.0.elements().is_empty());
let shared = craft_font_catalog::FontOutline::from_bytes(&bytes, 0, &[]).unwrap();
let (path, status) = shared.outline_recovering(gid).unwrap();
assert!(status.is_err());
assert_eq!(kurbo::Affine::scale_non_uniform(1.0, -1.0) * path, old.0);
}
}