diff --git a/README.md b/README.md index 1524546..0111036 100644 --- a/README.md +++ b/README.md @@ -520,7 +520,7 @@ advisory breaks, starred `\vspace`/`\hspace`, `center`, `\hrule`, `\fbox`, ## New-template compatibility -The SIVP class (`sn-jnl.cls`) loads completely and `sn-article.tex` exports a 12-page PDF; the Huawei E fragment (`projects/e/问题一.tex`) compiles to 16 A4 pages. This required generic TeX conditionals (`\if`, `\ifx`), `\newcount`/`\newdimen`, `\char`, 64-bit dimension scanning, `tabular*`/`tabularx` environments, and the math accent/operator/arrow vocabulary used by both documents. Both are covered by integration tests. +The SIVP class (`sn-jnl.cls`) loads completely and `sn-article.tex` previews and exports a 16-page PDF; the Huawei E fragment (`projects/e/问题一.tex`) compiles to 16 A4 pages. This required generic TeX conditionals (`\if`, `\ifx`), `\newcount`/`\newdimen`, `\char`, 64-bit dimension scanning, `tabular*`/`tabularx` environments, and the math accent/operator/arrow vocabulary used by both documents. Both are covered by integration tests. ## Capability matrix (current) diff --git a/assets/figure-placeholder.png b/assets/figure-placeholder.png new file mode 100644 index 0000000..0b02d3f Binary files /dev/null and b/assets/figure-placeholder.png differ diff --git a/docs/STATUS.md b/docs/STATUS.md index 063b643..611af8e 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -147,4 +147,4 @@ See `docs/ROADMAP.md` for concrete implementation plans. since printpdf 0.3.4 has no annotation API. - Fonts: bundled reserved-glyph subsets in `assets/fonts-subset/` are used when the document charset is covered; arXiv PDF is about 0.29 MB. -- New-template compatibility: the SIVP class file loads fully and `sn-article.tex` exports a 12-page PDF (live preview falls back on unsupported layout features); the Huawei E fragment compiles to 16 A4 pages. Generic support added for TeX `\if`/`\ifx`, `\newcount`, `\newdimen`, `\char`, `tabular*`/`tabularx`, math accents/operators/arrows, a 64-bit dimension scanner, and `geometry` `text={width,height}` blocks. Both fixtures are regression tests (`sivp_project_exports_a_pdf`, `e_fixture_compiles`). +- New-template compatibility: the SIVP class file loads fully and `sn-article.tex` previews and exports a 16-page PDF (PDF figures render as placeholders); the Huawei E fragment compiles to 16 A4 pages. Generic support added for TeX `\if`/`\ifx`, `\newcount`, `\newdimen`, `\char`, `tabular*`/`tabularx`, math accents/operators/arrows, a 64-bit dimension scanner, and `geometry` `text={width,height}` blocks. Both fixtures are regression tests (`sivp_project_previews_and_exports_a_pdf`, `e_fixture_compiles`). diff --git a/src/rust_typeset/pdf/layout.rs b/src/rust_typeset/pdf/layout.rs index bc105b0..2139a64 100644 --- a/src/rust_typeset/pdf/layout.rs +++ b/src/rust_typeset/pdf/layout.rs @@ -782,8 +782,21 @@ fn layout_figure( math_layout: &MathLayoutEnvironment, cache: &mut ParagraphLayoutCache, ) -> Option { - let image_path = resolved_image_path(source_dir, path); - let (pixel_width, pixel_height) = image::image_dimensions(&image_path).ok()?; + let requested_path = resolved_image_path(source_dir, path); + let is_pdf = requested_path + .extension() + .is_some_and(|extension| extension.eq_ignore_ascii_case("pdf")); + let (image_path, pixel_width, pixel_height) = match image::image_dimensions(&requested_path) { + Ok((width, height)) => (requested_path, width, height), + Err(_) if is_pdf => { + let placeholder = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("assets") + .join("figure-placeholder.png"); + let (width, height) = image::image_dimensions(&placeholder).ok()?; + (placeholder, width, height) + } + Err(_) => return None, + }; let (scale_x, scale_y) = image_scale( options, pixel_width, diff --git a/tests/typeset.rs b/tests/typeset.rs index a93271b..bb354f6 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -1852,8 +1852,11 @@ fn geometry_text_sets_the_text_block() { } #[test] -fn sivp_project_exports_a_pdf() { +fn sivp_project_previews_and_exports_a_pdf() { let source = std::fs::read_to_string("projects/_sivp__/sn-article.tex").unwrap(); + let value = fresh_preview(&source, "projects/_sivp__/sn-article.tex"); + assert_eq!(value["status"], "ok", "{value}"); + assert!(!pages(&value).is_empty()); let pdf = CompilerSession::default() .compile(&source, "projects/_sivp__/sn-article.tex") .expect("SIVP PDF");