Lottie: leave blank font families out of the embedded glyphs warning

A `chars` entry with an empty or whitespace-only `fFamily` listed an
empty name, so the warning read "of Sans, , Serif".
This commit is contained in:
JonRC committed 2026-11-02 13:42:27 -03:00
1 parent 1a9eeb9e1b
commit 7f6afdb51a
2 files changed
+7 -5

No files matched your search

+1 -1
View File
@@ -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);
}
+6 -4
View File
@@ -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]