diff --git a/crates/lottie/src/import.rs b/crates/lottie/src/import.rs index cc1bacea4..90519a8db 100644 --- a/crates/lottie/src/import.rs +++ b/crates/lottie/src/import.rs @@ -138,7 +138,7 @@ pub fn import( // 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")) { + for fam in chars.iter().filter_map(|c| s(c, "fFamily")).filter(|f| !f.trim().is_empty()) { if !fams.contains(&fam) { fams.push(fam); } diff --git a/crates/lottie/src/tests.rs b/crates/lottie/src/tests.rs index d8fcc5661..cbe89d58c 100644 --- a/crates/lottie/src/tests.rs +++ b/crates/lottie/src/tests.rs @@ -525,10 +525,12 @@ 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", "Sans"), glyph("C", "Serif")]}); - let mut q = Project::default(); - let imp = import(&mut q, doc.to_string().as_bytes(), "Imported", "", &mut |_| None).unwrap(); - assert_eq!(imp.warnings, ["embedded glyphs (`chars`) of Sans, Serif are not imported; text uses the installed fonts"]); + "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]