From 0a7b4b529bb449123376f394c39d60be7b2e7531 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 26 Oct 2026 12:31:07 -0400 Subject: [PATCH] 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 --- crates/redact/src/type3.rs | 6 +++++- crates/redact/src/type3_tables.rs | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/redact/src/type3.rs b/crates/redact/src/type3.rs index 0542e002e5..4f9a4206af 100644 --- a/crates/redact/src/type3.rs +++ b/crates/redact/src/type3.rs @@ -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); diff --git a/crates/redact/src/type3_tables.rs b/crates/redact/src/type3_tables.rs index e860a07581..c99917b0b0 100644 --- a/crates/redact/src/type3_tables.rs +++ b/crates/redact/src/type3_tables.rs @@ -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"),