diff --git a/crates/doc/src/image_quad.rs b/crates/doc/src/image_quad.rs index 8f514a3b71..f5b087125d 100644 --- a/crates/doc/src/image_quad.rs +++ b/crates/doc/src/image_quad.rs @@ -457,7 +457,7 @@ mod tests { n.transform(Affine::scale_non_uniform(1.0, 0.25), false); assert!(n.extras().image_quad.is_none()); let b = n.geometric_bounds().unwrap(); - assert!(b.height() < 1e-6 && (b.width() - 150.0).abs() < 60.0, "{b:?}"); + assert!(b.height() < 1e-6 && (b.x0 + 200.0 / 9.0).abs() < 1e-6 && (b.x1 - 1400.0 / 9.0).abs() < 1e-6, "{b:?}"); } /// A file's corners that the image cannot take are dropped as it is read, so a later scale diff --git a/crates/eps/src/import/tests_composite.rs b/crates/eps/src/import/tests_composite.rs index ff3b3382d3..6e3a63373d 100644 --- a/crates/eps/src/import/tests_composite.rs +++ b/crates/eps/src/import/tests_composite.rs @@ -64,8 +64,10 @@ fn type42_descendants_draw_their_own_glyphs() { } // The H, then the I one H's width along; both stand on the baseline, a cap height tall. let (bh, bi) = (bounds(paths[0]), bounds(paths[1])); - assert!((bh.x0 - 10.0).abs() < 8.0 && bh.width() > 20.0 && bh.width() < 50.0 * wh, "{bh:?}"); - assert!((bh.height() - bi.height()).abs() < 0.5 && bh.height() > 25.0 && bh.height() < 40.0, "{bh:?} {bi:?}"); + // The bundled font's H spans (90, 0)–(562, 656) of its 1000-unit em: at 50 pt from x = 10 that + // is 14.5 to 38.1, 32.8 tall. + assert!((bh.x0 - 14.5).abs() < 0.01 && (bh.width() - 23.6).abs() < 0.01 && (bh.height() - 32.8).abs() < 0.01, "{bh:?}"); + assert!((bh.height() - bi.height()).abs() < 0.5, "{bh:?} {bi:?}"); assert!(bi.x0 > 10.0 + 50.0 * wh - 1.0 && bi.x1 < 10.0 + 50.0 * (wh + wi), "{bi:?}"); } @@ -78,8 +80,12 @@ fn type42_descendants_measure_space_and_outline_their_glyphs() { check(format!("(\\000\\001\\000\\002) stringwidth pop {} sub abs 0.01 lt", 50.0 * (wh + wi))); // xyshow places each character where its numbers say. check("gsave nulldevice 10 20 moveto (\\000\\001\\000\\002) [30 0 7 0] xyshow currentpoint grestore pop 47 sub abs 0.01 lt".into()); - // charpath outlines them. - check("newpath 10 20 moveto (\\000\\001) true charpath pathbbox exch pop sub abs 25 gt exch 10 sub abs 8 lt and".into()); + // charpath outlines them: the H's box is (14.5, 20)–(38.1, 52.8). + check( + "newpath 10 20 moveto (\\000\\001) true charpath pathbbox 52.8 sub abs 0.01 lt exch 38.1 sub abs 0.01 lt and \ + exch 20 sub abs 0.01 lt and exch 14.5 sub abs 0.01 lt and" + .into(), + ); } /// A descendant that is a font by name only (its program isn't run) sets its characters as type, diff --git a/crates/metafile/src/tests/import.rs b/crates/metafile/src/tests/import.rs index 15eca240a9..42a66bc8d5 100644 --- a/crates/metafile/src/tests/import.rs +++ b/crates/metafile/src/tests/import.rs @@ -731,7 +731,8 @@ fn hatched_brushes_fill_with_their_average_color() { let p = paths(&back.document); assert_eq!(p.len(), 1); let [r, g, b] = fill_rgb(&p[0]).unwrap(); - assert!(b == 255 && r == g && r > 0 && r < 255, "{:?}", [r, g, b]); + // The horizontal hatch covers one row in eight of its 8 × 8 tile: 8 blue and 56 white pixels. + assert_eq!([r, g, b], [223, 223, 255]); // With a transparent background (SETBKMODE 1) the hatch is blue with gaps: a translucent fill. let mut records = records; records.insert(0, (18, le(&[1]))); @@ -739,7 +740,8 @@ fn hatched_brushes_fill_with_their_average_color() { let p = paths(&back.document); assert_eq!(fill_rgb(&p[0]), Some([0, 0, 255])); let AppearanceItem::Fill(f) = &p[0].appearance.items[0] else { panic!("a fill") }; - assert!(f.opacity > 0.0 && f.opacity < 1.0, "{}", f.opacity); + // One eighth of 255, truncated to 31. + assert!((f.opacity - 31.0 / 255.0).abs() < 1e-6, "{}", f.opacity); } #[test] diff --git a/crates/pdf/src/tests/import_options.rs b/crates/pdf/src/tests/import_options.rs index a419d64137..2205ae2a7f 100644 --- a/crates/pdf/src/tests/import_options.rs +++ b/crates/pdf/src/tests/import_options.rs @@ -272,7 +272,8 @@ fn a_page_without_area_gets_the_size_viewers_give_it() { let bytes = pdf(&[PdfPage { media: [0.0, 0.0, 0.0, 0.0], ..PdfPage::new(0.0, 0.0, "") }], None); let i = info(&bytes, None).unwrap(); let (w, h) = (i.pages[0].width, i.pages[0].height); - assert!(w > 0.0 && h > 0.0); + // US Letter, 8.5 × 11 in. + assert_eq!((w, h), (612.0, 792.0)); for crop in [CropTo::Crop, CropTo::Media, CropTo::Art] { let ab = open(&bytes, ImportOptions { crop, ..Default::default() }).artboards[0].rect; assert_eq!((ab.width(), ab.height()), (w, h), "{crop:?}"); diff --git a/crates/svg/tests/it/mesh_export.rs b/crates/svg/tests/it/mesh_export.rs index 78f30f50c9..c46b943734 100644 --- a/crates/svg/tests/it/mesh_export.rs +++ b/crates/svg/tests/it/mesh_export.rs @@ -84,6 +84,11 @@ fn a_patch_is_cut_no_finer_than_its_colour_changes() { let d = doc(2, 2, |_, c| Color::rgb8(100 + c as u8, 100 + c as u8, 100 + c as u8)); let svg = export(&d, &ExportOptions::default()); assert!(pieces(&svg) <= 4, "{} pieces", pieces(&svg)); + // Each piece takes its patch's middle color: 100.5 and 101.5 round to 101 and 102. + let mut fills: Vec<&str> = svg.split("fill=\"").skip(1).filter_map(|s| s.split('"').next()).filter(|f| f.starts_with('#')).collect(); + fills.sort_unstable(); + fills.dedup(); + assert_eq!(fills, ["#656565", "#666666"], "{svg}"); assert_looks_alike(&d, &svg, in_square, 2, 0.0); }