diff --git a/src/tables/names/encoding/macintosh.rs b/src/tables/names/encoding/macintosh.rs index ce14cc1..7d54e84 100644 --- a/src/tables/names/encoding/macintosh.rs +++ b/src/tables/names/encoding/macintosh.rs @@ -193,8 +193,10 @@ pub fn encode( } }; for character in value.chars() { - if let Some(value) = mapping.get(&character) { - data.push(*value); + if character as u16 <= 0x7F { + data.push(character as u8); + } else if let Some(value) = mapping.get(&character) { + data.push(*value | 0x80); } else { raise!("found an unknown Macintosh character ({character})") } diff --git a/tests/names.rs b/tests/names.rs index afd2ad0..0fc21fd 100644 --- a/tests/names.rs +++ b/tests/names.rs @@ -20,6 +20,23 @@ mod open_sans { #[test] fn read() { let table = ok!(Names::read(&mut setup!(OpenSans, "name"))); + test(&table); + } + + #[test] + fn write() { + let table = ok!(Names::read(&mut setup!(OpenSans, "name"))); + let records = table.iter().map(|(ids, value)| (ids, ok!(value))); + let language_tags = table.language_tags().map(Option::unwrap); + let table = ok!(Names::from_iter( + records, + language_tags, + &mut Default::default(), + )); + test(&table); + } + + fn test(table: &Names) { let records = table.iter().collect::>(); let name_ids = records .iter()