From 4d6873d1f7b35b7d82171162c81a5f7d79a61d77 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 23 Oct 2026 03:57:35 -0700 Subject: [PATCH] Tests: type across the widest canvas is drawn with its method The renderer now limits each render context to MAX_CONTEXT_SIDE (32,768) pixels a side, so a 40,000-pixel canvas is drawn 32,768 pixels wide and the type's offscreen drawing is never wider than that. type_wider_than_the_raster_limit_is_drawn_as_sharp expected None type on that canvas to be drawn as Sharp and failed. type_across_the_widest_canvas_is_drawn_with_its_method replaces it: "Hamburg" at 25,000% runs past both sides of a canvas MAX_CONTEXT_SIDE pixels wide, and None type paints whole pixels across it, each the share None gives the pixel of Sharp type. --- crates/render/src/tests_typeedges.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/crates/render/src/tests_typeedges.rs b/crates/render/src/tests_typeedges.rs index 509f93ce7e..855f20d465 100644 --- a/crates/render/src/tests_typeedges.rs +++ b/crates/render/src/tests_typeedges.rs @@ -482,17 +482,24 @@ fn type_edges_are_drawn_on_at_most_the_budgets_pixels() { assert_eq!(edge_grid(Rect::new(0.0, 0.0, 10_000.0, 1.0), coarser), Affine::IDENTITY, "40,000 pixels a side"); } -/// Type whose offscreen drawing would be more than `MAX_RASTER_SIDE` pixels a side is drawn as -/// Sharp type is. +/// Type across a canvas of the largest side the renderer draws (`MAX_CONTEXT_SIDE` pixels) is +/// drawn with its method on every pixel. #[test] -fn type_wider_than_the_raster_limit_is_drawn_as_sharp() { - // "Hamburg" at 25,000%, about 37,000 pixels wide, on four rows through its letters. - let view = Affine::translate((-2_000.0, -12_500.0)) * Affine::scale(250.0); - let draw = |m| Renderer::new().render(&page(m, None), 40_000, 4, view, &RenderOptions::default()).pixels; +fn type_across_the_widest_canvas_is_drawn_with_its_method() { + // "Hamburg" at 25,000%, about 37,000 pixels wide, past both sides of the canvas, on four rows + // through its letters. + let view = Affine::translate((-3_000.0, -12_500.0)) * Affine::scale(250.0); + let draw = |m| { + let pixels = Renderer::new().render(&page(m, None), MAX_CONTEXT_SIDE, 4, view, &RenderOptions::default()).pixels; + pixels.chunks(4).map(|p| p[3]).collect::>() + }; let sharp = draw(TypeAntiAlias::Sharp); - let a: Vec = sharp.chunks(4).map(|p| p[3]).collect(); - assert!(partial(&a) > 0, "the rows cross the edges of the letters"); - assert!(draw(TypeAntiAlias::None) == sharp, "None type is drawn as Sharp"); + assert!(partial(&sharp) > 0, "the rows cross the edges of the letters"); + let none = draw(TypeAntiAlias::None); + assert_eq!(none.len(), sharp.len()); + assert_eq!(partial(&none), 0, "None paints whole pixels"); + let wrong = off_the_share(TypeAntiAlias::None, &sharp, &none); + assert!(wrong.is_empty(), "(pixel, Sharp, drawn) {wrong:?}"); } /// The offscreen drawing takes in the farthest a stroke reaches: a mitered character stroke's