This commit is contained in:
Brandon Thomas committed 2026-11-03 09:04:45 -05:00
commit f13aef1655
2 files changed
+24

No files matched your search

+11
View File
@@ -135,6 +135,17 @@ pub fn import(
cx.fonts.push((n, fam, st));
}
}
// Glyph outlines embedded for players without the fonts. Text is set in installed fonts.
if let Some(chars) = doc.get("chars").and_then(Json::as_array).filter(|c| !c.is_empty()) {
let mut fams: Vec<&str> = vec![];
for fam in chars.iter().filter_map(|c| s(c, "fFamily")).filter(|f| !f.trim().is_empty()) {
if !fams.contains(&fam) {
fams.push(fam);
}
}
let of = if fams.is_empty() { String::new() } else { format!(" of {}", fams.join(", ")) };
cx.im.warn(format!("embedded glyphs (`chars`){of} are not imported; text uses the installed fonts"));
}
let (w, h) = (w.round().max(1.0) as u32, h.round().max(1.0) as u32);
let duration = tb.tick(op);
// Pass 1: asset items (precomps empty for now, images stored).
+13
View File
@@ -520,6 +520,19 @@ fn zero_time_stretch_is_not_imported() {
assert!(imp.warnings.iter().any(|w| w.contains("time stretch")), "{:?}", imp.warnings);
}
#[test]
fn embedded_glyphs_are_reported_when_dropped() {
let glyph = |ch: &str, fam: &str| json!({"ch": ch, "size": 100, "style": "Regular", "w": 60, "fFamily": fam, "data": {"shapes": []}});
let doc = json!({"w": 20, "h": 20, "fr": 30, "ip": 0, "op": 30, "assets": [], "layers": [],
"fonts": {"list": [{"fName": "Sans-Regular", "fFamily": "Sans", "fStyle": "Regular"}]},
"chars": [glyph("A", "Sans"), glyph("B", ""), glyph("C", "Serif")]});
let warnings = |doc: &Json| import(&mut Project::default(), doc.to_string().as_bytes(), "Imported", "", &mut |_| None).unwrap().warnings;
// A blank family name is left out, not listed as "of , …".
assert_eq!(warnings(&doc), ["embedded glyphs (`chars`) of Sans, Serif are not imported; text uses the installed fonts"]);
let blank = json!({"w": 20, "h": 20, "fr": 30, "layers": [], "chars": [glyph("A", " ")]});
assert_eq!(warnings(&blank), ["embedded glyphs (`chars`) are not imported; text uses the installed fonts"]);
}
#[test]
fn precomp_with_time_remap() {
let (mut p, cid) = setup();