From cf9f6066f2040ebe101eeb5fdc6a7c58780bdc86 Mon Sep 17 00:00:00 2001 From: Phillip Tennen Date: Sun, 5 Feb 2023 15:16:28 +0000 Subject: [PATCH] [Rust] Accept extended Unicode character maps --- rust_programs/ttf_renderer/src/parser.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/rust_programs/ttf_renderer/src/parser.rs b/rust_programs/ttf_renderer/src/parser.rs index da5b32920..8dd6e8394 100644 --- a/rust_programs/ttf_renderer/src/parser.rs +++ b/rust_programs/ttf_renderer/src/parser.rs @@ -654,10 +654,17 @@ impl<'a> FontParser<'a> { .find_map(|_| { let character_map_subtable = CharacterMapSubtable::from_in_place_buf(self.read_with_cursor(&mut cursor)); - if character_map_subtable.platform_and_encoding - == CharacterMapPlatformAndEncoding::Unicode( + println!("Character map subtable {character_map_subtable:?}"); + let recognized_unicode_encodings = [ + CharacterMapPlatformAndEncoding::Unicode( CharacterMapUnicodeEncoding::Version2_0Bmp, - ) + ), + CharacterMapPlatformAndEncoding::Unicode( + CharacterMapUnicodeEncoding::Version2_0Extended, + ), + ]; + if recognized_unicode_encodings + .contains(&character_map_subtable.platform_and_encoding) { Some(character_map_subtable.offset) } else { @@ -726,7 +733,7 @@ impl<'a> FontParser<'a> { let segment_ranges: Vec> = segment_start_character_codes .iter() .zip(segment_last_character_codes.iter()) - .map(|(&start, &end)| (start as usize..end as usize)) + .map(|(&start, &end)| (start as usize..end as usize + 1)) .collect(); println!("Segment ranges: {segment_ranges:?}");