Preview SIVP with placeholders for PDF figures

This commit is contained in:
gloamxun committed 2026-10-20 00:37:56 +08:00
1 parent ac3e42a201
commit 82542740e7
5 files changed
+21 -5

No files matched your search

+15 -2
View File
@@ -782,8 +782,21 @@ fn layout_figure(
math_layout: &MathLayoutEnvironment,
cache: &mut ParagraphLayoutCache,
) -> Option<PositionedFigure> {
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,