From b457c86d4f151f16d842ead3daec3702ff5fb0e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BA=A7n=20=C4=90=C3=ACnh=20Nam?= Date: Sat, 8 Aug 2026 02:40:51 +0700 Subject: [PATCH] Fix tang coverage cua SetText: chi ap dung cho font NHUNG - voi font khong nhung, PDFium moi tra bytes cua font he thong thay the (phu du glyph Viet) lam engine tuong set_text an toan, nhung font object WinAnsi trong PDF khong ma hoa duoc -> ra ky tu rac. Bug tiem an tu iteration 2, lo ra khi CI dung DLL bblanchon moi (may dev cu DLL cu khong tra data cho font khong nhung). Co-Authored-By: Claude Fable 5 --- crates/ff-engine/src/edit.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/ff-engine/src/edit.rs b/crates/ff-engine/src/edit.rs index 44623f0..b1289dd 100644 --- a/crates/ff-engine/src/edit.rs +++ b/crates/ff-engine/src/edit.rs @@ -754,12 +754,18 @@ pub fn apply_edits( SetTextMode::InPlace } else if non_embedded && ascii_only { SetTextMode::InPlace - } else if t - .font() - .data() - .ok() - .map_or(false, |bytes| fontmatch::coverage_ok(&bytes, text)) + } else if !non_embedded + && t + .font() + .data() + .ok() + .map_or(false, |bytes| fontmatch::coverage_ok(&bytes, text)) { + // Tầng coverage CHỈ cho font NHÚNG: với font không + // nhúng, PDFium (bản mới) trả bytes của font HỆ THỐNG + // thay thế — phủ đủ glyph không có nghĩa font object + // trong PDF (simple font WinAnsi) mã hoá được text + // mới; set_text khi đó ra charcode rác (ÿ). SetTextMode::InPlace } else { let (key, bytes) = resolve_substitute_font(