Fix Type 3 encoding entries and keep the font on an unmatched Q

WIN_ANSI[160] and MAC_ROMAN[202] map to space, and WIN_ANSI[173] maps to hyphen, matching the PDF encodings instead of the nbspace and sfthyphen names. An unmatched Q no longer resets the current font, so later glyphs stay recorded.

Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
Dylan M. Taylor
2026-10-26 12:31:07 -04:00
parent a1ec5e908c
commit 0a7b4b529b
2 changed files with 8 additions and 4 deletions
+5 -1
View File
@@ -248,7 +248,11 @@ fn scan_content_stream(
for op in parsed.ops {
match op.op.as_slice() {
b"q" => stack.push(current_font),
b"Q" => current_font = stack.pop().unwrap_or(None),
b"Q" => {
if let Some(saved) = stack.pop() {
current_font = saved;
}
}
b"Tf" => {
if let Some(name) = op.name(0) {
current_font = resolve_font_in_res(ctx.doc, res, name).map(|(k, _)| k);
+3 -3
View File
@@ -420,7 +420,7 @@ pub(crate) static WIN_ANSI: [Option<&[u8]>; 256] = [
None,
Some(b"zcaron"),
Some(b"Ydieresis"),
Some(b"nbspace"),
Some(b"space"),
Some(b"exclamdown"),
Some(b"cent"),
Some(b"sterling"),
@@ -433,7 +433,7 @@ pub(crate) static WIN_ANSI: [Option<&[u8]>; 256] = [
Some(b"ordfeminine"),
Some(b"guillemotleft"),
Some(b"logicalnot"),
Some(b"sfthyphen"),
Some(b"hyphen"),
Some(b"registered"),
Some(b"macron"),
Some(b"degree"),
@@ -721,7 +721,7 @@ pub(crate) static MAC_ROMAN: [Option<&[u8]>; 256] = [
Some(b"guillemotleft"),
Some(b"guillemotright"),
Some(b"ellipsis"),
Some(b"nbspace"),
Some(b"space"),
Some(b"Agrave"),
Some(b"Atilde"),
Some(b"Otilde"),