Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prove no outlines take no glyf space #424

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions fontc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1756,4 +1756,29 @@ mod tests {
]
);
}

#[test]
fn empty_glyph_is_zero_length() {
let temp_dir = tempdir().unwrap();
let build_dir = temp_dir.path();
let result = compile(Args::for_test(build_dir, "glyphs2/WghtVar.glyphs"));

let space_idx = result.get_glyph_index("space") as usize;

let font_file = build_dir.join("font.ttf");
assert!(font_file.exists());
let buf = fs::read(font_file).unwrap();
let font = FontRef::new(&buf).unwrap();
let is_long = match font.head().unwrap().index_to_loc_format() {
0 => false,
1 => true,
_ => panic!("Unrecognized loca format"),
};
let loca = font.loca(is_long).unwrap();
assert_eq!(
loca.get_raw(space_idx).unwrap(),
loca.get_raw(space_idx + 1).unwrap(),
"space has no outline and should take 0 bytes of glyf"
);
}
}