Skip to content

Commit

Permalink
Fix lowercase s of Procset and no space target string(#323) (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
seongs1024 authored Sep 12, 2024
1 parent 0d34b64 commit 709bd30
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/extract_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fn filter_func(object_id: (u32, u16), object: &mut Object) -> Option<((u32, u16)
d.remove(b"ModDate");
d.remove(b"Creator");
d.remove(b"ProcSet");
d.remove(b"Procset");
d.remove(b"XObject");
d.remove(b"MediaBox");
d.remove(b"Annots");
Expand Down
1 change: 1 addition & 0 deletions examples/extract_toc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fn filter_func(object_id: (u32, u16), object: &mut Object) -> Option<((u32, u16)
d.remove(b"ModDate");
d.remove(b"Creator");
d.remove(b"ProcSet");
d.remove(b"Procset");
d.remove(b"XObject");
d.remove(b"MediaBox");
d.remove(b"Annots");
Expand Down
29 changes: 27 additions & 2 deletions src/nom_cmap_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn cidinit_procset(input: ParserInput) -> NomResult<()> {
(
tag(b"/CIDInit"),
space0,
tag(b"/ProcSet"),
alt((tag(b"/ProcSet"), tag(b"/Procset"))),
space1,
tag(b"findresource"),
space1,
Expand Down Expand Up @@ -171,7 +171,7 @@ fn hex_u16(input: ParserInput) -> NomResult<u16> {
fn bf_char_section(input: ParserInput) -> NomResult<CMapSection> {
let begin_section = tuple((digit1, space1, tag(b"beginbfchar"), multispace1));
let end_section = tuple((tag(b"endbfchar"), multispace1));
let bf_char_line = delimited(space0, separated_pair(source_code, space1, target_string), multispace1);
let bf_char_line = delimited(space0, separated_pair(source_code, space0, target_string), multispace1);
let (rest_of_input, bf_char_mappings) = delimited(begin_section, many1(bf_char_line), end_section)(input)?;
Ok((rest_of_input, CMapSection::BfChar(bf_char_mappings)))
}
Expand Down Expand Up @@ -853,6 +853,31 @@ endbfchar
endcmap
CMapName currentdict /CMap defineresource pop
end
end\n";
assert!(cmap_stream(data).is_ok())
}

#[test]
fn parse_cmap_section_with_lowercase_pracset_and_nospace_target_string() {
let data = b"/CIDInit /Procset findresource begin
12 dict begin
begincmap
/CMapType 2 def
1 begincodespacerange
<0000><ffff>
endcodespacerange
4 beginbfchar
<1D50><AC1C>
<1E29><ACF5>
<43ED><D2B9>
<46FC><D5C8>
endbfchar
1 beginbfrange
<067B><0692><0020>
endbfrange
endcmap
CMapName currentdict /CMap defineresource pop
end
end\n";
assert!(cmap_stream(data).is_ok())
}
Expand Down

0 comments on commit 709bd30

Please sign in to comment.