Skip to content

Commit

Permalink
[Rust] Accept extended Unicode character maps
Browse files Browse the repository at this point in the history
  • Loading branch information
codyd51 committed Feb 5, 2023
1 parent d273bb9 commit cf9f606
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions rust_programs/ttf_renderer/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -726,7 +733,7 @@ impl<'a> FontParser<'a> {
let segment_ranges: Vec<Range<usize>> = 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:?}");

Expand Down

0 comments on commit cf9f606

Please sign in to comment.