Resolve graphics through graphicspath directories

This commit is contained in:
gloamxun committed 2026-10-24 23:35:14 +08:00
1 parent 46f86c771e
commit 9aacb91184
6 files changed
+118 -8

No files matched your search

+47
View File
@@ -1733,3 +1733,50 @@ fn project_preview_and_pdf_embed_images() {
assert_eq!(pdf.status, 200);
assert_eq!(pdf.header("x-texrra-cache"), Some("miss"));
}
#[test]
fn project_images_resolve_through_graphicspath() {
let server = TestServer::start("route-d-graphicspath");
let image = two_by_two_bmp();
let put = server.request(
"PUT",
"/api/projects/hello/file?path=figures/pixel.bmp",
&image,
"image/bmp",
);
assert_eq!(put.status, 200, "{}", put.text());
let main = "\\documentclass{article}\n\\graphicspath{{figures/}}\n\\begin{document}\n\\begin{figure}[t]\n\\includegraphics[width=60pt]{pixel}\n\\caption{Placed}\n\\end{figure}\n\\end{document}\n";
let put = server.request(
"PUT",
"/api/projects/hello/file?path=hello.tex",
main.as_bytes(),
"text/plain; charset=utf-8",
);
assert_eq!(put.status, 200, "{}", put.text());
let preview = server.request(
"POST",
"/api/projects/hello/preview?engine=route-d",
&[],
"application/json",
);
assert_eq!(preview.status, 200, "{}", preview.text());
let svg = preview.text();
assert!(svg.contains(r##"fill=\"#cccccc\""##), "preview: {svg}");
assert!(svg.contains(">P</text>"), "preview: {svg}");
assert!(!svg.contains("graphicspath"), "preview: {svg}");
let pdf = server.request(
"POST",
"/api/projects/hello/pdf?engine=route-d",
&[],
"application/pdf",
);
assert_eq!(pdf.status, 200);
assert!(
pdf.body
.windows("/Subtype /Image".len())
.any(|window| window == b"/Subtype /Image"),
"pdf should embed the image resolved through graphicspath"
);
}