Resolve imported PDF CFF device fonts from real OpenType faces

This commit is contained in:
gloamxun committed 2026-11-28 04:35:52 +08:00
1 parent 84d6f3ae51
commit 82e54894c4
14 files changed
+326 -38

No files matched your search

+29
View File
@@ -2192,6 +2192,35 @@ fn mapped_opentype_cff_paints_reencoded_glyphs_and_embeds_the_original_table() {
assert_eq!(embedded.content[0], 1);
assert!(source.windows(embedded.content.len()).any(|bytes| bytes == embedded.content));
let mut included = pdf;
for object in included.objects.values_mut() {
if let Ok(dict) = object.as_dict_mut() {
dict.remove(b"FontFile3");
}
}
included.prune_objects();
included.save(root.join("external.pdf")).unwrap();
fs::write(root.join("import.tex"), br"\catcode123=1 \catcode125=2
\pdfoutput=1 \pdfcompresslevel=0
\pdfximage width180pt {external.pdf}
\shipout\hbox{\pdfrefximage\pdflastximage}
\end
").unwrap();
let mut imported = job.clone();
imported.input = root.join("import.tex");
imported.output = PathBuf::from("import.pdf");
imported.world.paths.insert(ResourceKind::Type1, vec![SearchPath::directory(&root, false)]);
let result = NativeCompiler::default().compile(imported).unwrap();
let preview = result.preview_since(None).unwrap();
assert!(preview.pages[0].svg.matches("<use").count() >= 2);
assert!(result.resources.trace.reads.contains(
&file_version(&root.join("lmroman10-regular.otf")).unwrap().unwrap(),
));
let published = lopdf::Document::load_mem(result.pdf.as_deref().unwrap()).unwrap();
assert!(!published.objects.values().any(
|object| object.as_dict().is_ok_and(|dict| dict.has(b"FontFile3"))
));
fs::remove_file(root.join("lm-ec.enc")).unwrap();
let error = compiler.compile_detailed(job).err().unwrap().error.to_string();
assert!(error.contains("lm-ec.enc"), "{error}");