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

leave generated .notdef glyph unmapped in cmap #428

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions fontc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,6 @@ mod tests {
.collect();
assert_eq!(
vec![
(0x0000, 0),
(0x002C, 2),
(0x002E, 1),
(0x0030, 3),
Expand Down Expand Up @@ -1288,10 +1287,12 @@ mod tests {
let buf = fs::read(font_file).unwrap();
let font = FontRef::new(&buf).unwrap();

assert_eq!(
GlyphId::new(0),
font.cmap().unwrap().map_codepoint(0u32).unwrap()
);
// Character 0x0000 (NULL) != '.notdef' glyph, and neither are any other
// characters actually, because '.notdef' (glyph index 0) means the absence
// of a character-to-glyph mapping:
// https://github.com/googlefonts/fontc/pull/423/files#r1309257127
// https://learn.microsoft.com/en-us/typography/opentype/spec/cmap#overview
assert_eq!(None, font.cmap().unwrap().map_codepoint(0u32));
}

#[test]
Expand All @@ -1312,13 +1313,12 @@ mod tests {

assert_eq!(
vec![
GlyphId::new(0),
GlyphId::new(1),
GlyphId::new(2),
GlyphId::new(3),
GlyphId::new(6),
],
[0x00, 0x20, 0x21, 0x2d, 0x3d]
[0x20, 0x21, 0x2d, 0x3d]
.iter()
.map(|cp| font.cmap().unwrap().map_codepoint(*cp as u32).unwrap())
.collect::<Vec<_>>()
Expand Down
2 changes: 1 addition & 1 deletion fontir/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ impl GlyphBuilder {

Self {
name: GlyphName::NOTDEF.clone(),
codepoints: HashSet::from([0]),
codepoints: HashSet::new(),
sources: HashMap::from([(
default_location,
GlyphInstance {
Expand Down