Track PDF literal transforms in native source maps

This commit is contained in:
gloamxun committed 2026-11-21 02:23:12 +08:00
1 parent d46d6d79a8
commit 7f74251c8a
9 files changed
+303 -22

No files matched your search

+26
View File
@@ -199,6 +199,32 @@ fn replacing_a_type1_program_at_the_same_path_updates_native_pdf_and_preview() {
fs::remove_dir_all(p).unwrap();
}
#[test]
fn literal_text_position_is_unmapped_until_the_next_native_text_object() {
use texrra_tex_core::source_map::{PaintKind, UnmappedReason};
let path = directory("literal-text-source-map");
write(
&path,
r"\pdfoutput=1 \pdfpagewidth=90pt \pdfpageheight=70pt
\shipout\hbox{A\pdfliteral direct{4 0 Td}B\pdfliteral page{}C}\end",
);
let compiled = NativeCompiler::default().compile(request(&path)).unwrap();
let page = &compiled.source_map.pages[0];
let glyphs: Vec<_> = page
.entries
.iter()
.filter_map(|entry| match entry.kind {
PaintKind::Glyph { slot, .. } => Some(slot),
_ => None,
})
.collect();
assert_eq!(glyphs, b"AC");
assert_eq!(page.unmapped.len(), 1);
assert_eq!(page.unmapped[0].reason, UnmappedReason::UnsupportedPrimitive);
fs::remove_dir_all(path).unwrap();
}
#[test]
fn graphics_transform_updates_preview_and_source_bounds_without_remeasuring_the_box() {
use texrra_tex_core::{pdf_device::PdfGraphics, render::DisplayItem, source_map::Bounds};