From 4ca6a57f056045263bea7763f581413ccaf9df5b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 7 Nov 2026 09:37:50 -0800 Subject: [PATCH 1/2] linesweeper: a leading ClosePath no longer panics in Topology and binary_op A BezPath deserialized from [ClosePath] or [ClosePath, MoveTo, LineTo, LineTo, ClosePath] made Topology::from_path and binary_op panic in kurbo with "Can't start a segment on a ClosePath". add_path_without_updating_enter_exit and the bounding box in binary_op now skip a ClosePath that comes before the first point. README.craft.md, SOURCE.json and NOTICE record the local patch. --- NOTICE | 6 ++-- vendor/linesweeper/README.craft.md | 22 +++++++++----- vendor/linesweeper/SOURCE.json | 8 +++-- vendor/linesweeper/src/lib.rs | 48 +++++++++++++++++++++++++++++- vendor/linesweeper/src/segments.rs | 11 ++++++- 5 files changed, 80 insertions(+), 15 deletions(-) diff --git a/NOTICE b/NOTICE index bd88d43e7a..70c163182c 100644 --- a/NOTICE +++ b/NOTICE @@ -218,10 +218,10 @@ applications retain their own document-font selection and licensing policy. linesweeper linesweeper 0.5.0 (https://crates.io/crates/linesweeper/0.5.0), MIT OR Apache-2.0, is stored in -vendor/linesweeper with its upstream license files and no file changed. Its manifest names Joe Neeman +vendor/linesweeper with its upstream license files and one local patch. Its manifest names Joe Neeman as author, and its LICENSE-MIT reads "Copyright (c) 2018 Raph Levien". See -vendor/linesweeper/README.craft.md and vendor/linesweeper/SOURCE.json for provenance and the files -left out. +vendor/linesweeper/README.craft.md and vendor/linesweeper/SOURCE.json for provenance, the local +change and the files left out. Platform lifecycle source provenance diff --git a/vendor/linesweeper/README.craft.md b/vendor/linesweeper/README.craft.md index f683ca53de..9d164301da 100644 --- a/vendor/linesweeper/README.craft.md +++ b/vendor/linesweeper/README.craft.md @@ -1,15 +1,23 @@ # Local linesweeper 0.5.0 copy -This is the crates.io linesweeper 0.5.0 package (MIT OR Apache-2.0) with some files left out and no -file changed. `.cargo_vcs_info.json` names the commit it was packaged from, +This is the crates.io linesweeper 0.5.0 package (MIT OR Apache-2.0) with some files left out and the +changes listed under Local changes. `.cargo_vcs_info.json` names the commit it was packaged from, `824b0791a750f7b27b8edcbb6c6244d0e629875e`. That commit is not in the GitHub repository the manifest names, which is archived; its README says development moved off GitHub. -Every file here except this one and `SOURCE.json` is byte for byte the file in the `.crate` archive. -`SOURCE.json` records the hash of the `.crate` download (`source_archive_sha256`) and, for every file -kept, the hash in the package (`source_sha256`) and the hash here (`sha256`). `upstream_repository` is -null because no public repository this copy can name holds `upstream_revision`. `local_patches` is -empty. +Every file here except this one, `SOURCE.json` and the files under Local changes is byte for byte the +file in the `.crate` archive. `SOURCE.json` records the hash of the `.crate` download +(`source_archive_sha256`) and, for every file kept, the hash in the package (`source_sha256`) and the +hash here (`sha256`). `upstream_repository` is null because no public repository this copy can name +holds `upstream_revision`. `local_patches` describes each local change. + +## Local changes + +| Change | Code comment label | Touches | Tests | +|---|---|---|---| +| `Topology::from_path`, the other `Topology` constructors that take Bézier paths, `Segments::add_bez_path` and `binary_op` skip a `ClosePath` that comes before the first point of a path instead of panicking with "Can't start a segment on a ClosePath" | `Craft patch (leading ClosePath)` | `src/segments.rs`, `src/lib.rs` | `tests::leading_close_path` | + +Every change here updates this table and `SOURCE.json` in the same commit. `omitted_files` lists the 43 files of the package left out here, with their hashes: diff --git a/vendor/linesweeper/SOURCE.json b/vendor/linesweeper/SOURCE.json index 9c71e51add..78430add5c 100644 --- a/vendor/linesweeper/SOURCE.json +++ b/vendor/linesweeper/SOURCE.json @@ -7,7 +7,9 @@ "upstream_repository": null, "upstream_revision": "824b0791a750f7b27b8edcbb6c6244d0e629875e", "upstream_directory": "", - "local_patches": [], + "local_patches": [ + "In `src/segments.rs` and `src/lib.rs`, a `ClosePath` that comes before the first point of a path is skipped. Without it, a `BezPath` deserialized from `[ClosePath]` or `[ClosePath, MoveTo, LineTo, LineTo, ClosePath]` makes `Topology::from_path` and `binary_op` panic in kurbo with \"Can't start a segment on a ClosePath\". With it, `[ClosePath]` gives no contours and the second path gives the same contours as the path without its leading `ClosePath`. The test `tests::leading_close_path` covers it." + ], "files": [ { "path": ".cargo_vcs_info.json", "source_sha256": "47fba6a9dbdf445a5c97f783c9be62093035f9d5e5cdc2cf3216ad8259bcd8fc", "source_git_blob": null, "sha256": "47fba6a9dbdf445a5c97f783c9be62093035f9d5e5cdc2cf3216ad8259bcd8fc" }, { "path": ".gitignore", "source_sha256": "88b59092499ae05234330eb7d0b01e953e969caf05261530e3765eef02536cf0", "source_git_blob": null, "sha256": "88b59092499ae05234330eb7d0b01e953e969caf05261530e3765eef02536cf0" }, @@ -37,12 +39,12 @@ { "path": "src/curve/transverse.rs", "source_sha256": "be9c695531f4cb0fe73af13e78040b51b9476c193d84562e701aadd07b3fd06e", "source_git_blob": null, "sha256": "be9c695531f4cb0fe73af13e78040b51b9476c193d84562e701aadd07b3fd06e" }, { "path": "src/generators.rs", "source_sha256": "cc9f2441546db9204219294c354449809dda77dffad06fec8a30f45df01e6fef", "source_git_blob": null, "sha256": "cc9f2441546db9204219294c354449809dda77dffad06fec8a30f45df01e6fef" }, { "path": "src/geom.rs", "source_sha256": "9878ffa6d4a13fa2c9149741c137205ca01acb626a5b9f86a3db75cf91b63a08", "source_git_blob": null, "sha256": "9878ffa6d4a13fa2c9149741c137205ca01acb626a5b9f86a3db75cf91b63a08" }, - { "path": "src/lib.rs", "source_sha256": "761c153c3b5c449569ff85c571344b9252ea64f7f0b0424fb4819041b03d13c6", "source_git_blob": null, "sha256": "761c153c3b5c449569ff85c571344b9252ea64f7f0b0424fb4819041b03d13c6" }, + { "path": "src/lib.rs", "source_sha256": "761c153c3b5c449569ff85c571344b9252ea64f7f0b0424fb4819041b03d13c6", "source_git_blob": null, "sha256": "584c3876a229ec9dae42410db35d21c1e0b25fd84ef6872372261556cdfa6613" }, { "path": "src/num.rs", "source_sha256": "39ff85da50c500ce91cf6dea81aedc0dcca1db5e7d0506696dde2da118e93a2a", "source_git_blob": null, "sha256": "39ff85da50c500ce91cf6dea81aedc0dcca1db5e7d0506696dde2da118e93a2a" }, { "path": "src/order.rs", "source_sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596", "source_git_blob": null, "sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596" }, { "path": "src/perturbation.rs", "source_sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5", "source_git_blob": null, "sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5" }, { "path": "src/position.rs", "source_sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0", "source_git_blob": null, "sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0" }, - { "path": "src/segments.rs", "source_sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc", "source_git_blob": null, "sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc" }, + { "path": "src/segments.rs", "source_sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc", "source_git_blob": null, "sha256": "8c0e51917e5cfb4f246218a241df88705e536806123c177fe47fb5790423d2a1" }, { "path": "src/snapshots/linesweeper__tests__empty_horizontals.snap", "source_sha256": "e319881853e889badf6524f19af4cd6f112e8dd71bdc516826f4463134a82244", "source_git_blob": null, "sha256": "e319881853e889badf6524f19af4cd6f112e8dd71bdc516826f4463134a82244" }, { "path": "src/snapshots/linesweeper__tests__two_squares.snap", "source_sha256": "01961e0311a5af3b8f13eb52a2a7112560c47cf86771c04e40475dc6f15a0846", "source_git_blob": null, "sha256": "01961e0311a5af3b8f13eb52a2a7112560c47cf86771c04e40475dc6f15a0846" }, { "path": "src/snapshots/linesweeper__topology__tests__diamond.snap", "source_sha256": "cfaefd620a0a3d1376861bca09cd7c658ef00a32635b88f1b259a9b39cd15502", "source_git_blob": null, "sha256": "cfaefd620a0a3d1376861bca09cd7c658ef00a32635b88f1b259a9b39cd15502" }, diff --git a/vendor/linesweeper/src/lib.rs b/vendor/linesweeper/src/lib.rs index 7d2500d095..04ea62eebf 100644 --- a/vendor/linesweeper/src/lib.rs +++ b/vendor/linesweeper/src/lib.rs @@ -107,7 +107,18 @@ pub fn binary_op( op: BinaryOp, ) -> Result { // Find the extremal values, to figure out how much precision we can support. - let bbox = set_a.bounding_box().union(set_b.bounding_box()); + // Craft patch (leading ClosePath): `BezPath::bounding_box` panics on a leading ClosePath. + let bounding_box = |path: &kurbo::BezPath| { + if matches!(path.elements().first(), Some(kurbo::PathEl::ClosePath)) { + kurbo::segments(segments::skip_leading_close_paths(path.iter())) + .map(|seg| kurbo::ParamCurveExtrema::bounding_box(&seg)) + .reduce(|a, b| a.union(b)) + .unwrap_or_default() + } else { + path.bounding_box() + } + }; + let bbox = bounding_box(set_a).union(bounding_box(set_b)); let min = bbox.min_x().min(bbox.min_y()); let max = bbox.max_x().max(bbox.max_y()); if min.is_infinite() || max.is_infinite() { @@ -205,6 +216,41 @@ mod tests { insta::assert_ron_snapshot!(output); } + // Craft patch (leading ClosePath). + #[test] + fn leading_close_path() { + // `BezPath`'s own constructors reject these, but deserializing does not. + let close_only: BezPath = serde_json::from_str(r#"["ClosePath"]"#).unwrap(); + let triangle = r#"{"MoveTo":{"x":0.0,"y":0.0}},{"LineTo":{"x":10.0,"y":0.0}},{"LineTo":{"x":0.0,"y":10.0}},"ClosePath""#; + let plain: BezPath = serde_json::from_str(&format!("[{triangle}]")).unwrap(); + let leading: BezPath = + serde_json::from_str(&format!(r#"["ClosePath",{triangle}]"#)).unwrap(); + + let empty = Topology::::from_path(&close_only, 1e-6).unwrap(); + assert_eq!(empty.contours(|w| *w != 0).contours().count(), 0); + + let expected = Topology::::from_path(&plain, 1e-6) + .unwrap() + .contours(|w| *w != 0); + let actual = Topology::::from_path(&leading, 1e-6) + .unwrap() + .contours(|w| *w != 0); + let paths = + |c: &topology::Contours| c.contours().map(|c| c.path.clone()).collect::>(); + assert_eq!(paths(&actual), paths(&expected)); + assert_eq!(paths(&actual).len(), 1); + + for (a, b) in [ + (&close_only, &plain), + (&plain, &close_only), + (&leading, &plain), + (&plain, &leading), + ] { + let output = binary_op(a, b, FillRule::NonZero, BinaryOp::Union).unwrap(); + assert_eq!(output.contours().count(), 1); + } + } + // This example has a union of two not-quite-axis-aligned crosses. It // suffers from some extra quadratic segments near the intersection points, // but it used to be worse. diff --git a/vendor/linesweeper/src/segments.rs b/vendor/linesweeper/src/segments.rs index 909eb01d2e..dd3522fa5b 100644 --- a/vendor/linesweeper/src/segments.rs +++ b/vendor/linesweeper/src/segments.rs @@ -131,6 +131,15 @@ fn pairs(xs: &[T]) -> impl Iterator { xs.windows(2).map(|pair| (&pair[0], &pair[1])) } +// Craft patch (leading ClosePath): `kurbo::segments` panics on a ClosePath that comes before +// any point, so such ClosePaths are dropped first. They draw nothing. +pub(crate) fn skip_leading_close_paths( + path: impl IntoIterator, +) -> impl Iterator { + path.into_iter() + .skip_while(|el| matches!(el, kurbo::PathEl::ClosePath)) +} + struct SubpathIter<'a, I: Iterator> { inner: &'a mut Peekable, started: bool, @@ -325,7 +334,7 @@ impl Segments { }; while let Some(subpath) = subpaths.next() { let old_len = self.segs.len(); - for seg in kurbo::segments(subpath) { + for seg in kurbo::segments(skip_leading_close_paths(subpath)) { let pieces = monotonic_pieces(seg); for monotonic in pieces { self.push_seg(monotonic.piece); From a7ebe01f054c05508bb257a050b32f9d3a29fb60 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 7 Nov 2026 10:33:40 -0800 Subject: [PATCH 2/2] linesweeper: record the committed bytes' digests for lib.rs and segments.rs --- vendor/linesweeper/SOURCE.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/linesweeper/SOURCE.json b/vendor/linesweeper/SOURCE.json index 78430add5c..b2966e72ce 100644 --- a/vendor/linesweeper/SOURCE.json +++ b/vendor/linesweeper/SOURCE.json @@ -39,12 +39,12 @@ { "path": "src/curve/transverse.rs", "source_sha256": "be9c695531f4cb0fe73af13e78040b51b9476c193d84562e701aadd07b3fd06e", "source_git_blob": null, "sha256": "be9c695531f4cb0fe73af13e78040b51b9476c193d84562e701aadd07b3fd06e" }, { "path": "src/generators.rs", "source_sha256": "cc9f2441546db9204219294c354449809dda77dffad06fec8a30f45df01e6fef", "source_git_blob": null, "sha256": "cc9f2441546db9204219294c354449809dda77dffad06fec8a30f45df01e6fef" }, { "path": "src/geom.rs", "source_sha256": "9878ffa6d4a13fa2c9149741c137205ca01acb626a5b9f86a3db75cf91b63a08", "source_git_blob": null, "sha256": "9878ffa6d4a13fa2c9149741c137205ca01acb626a5b9f86a3db75cf91b63a08" }, - { "path": "src/lib.rs", "source_sha256": "761c153c3b5c449569ff85c571344b9252ea64f7f0b0424fb4819041b03d13c6", "source_git_blob": null, "sha256": "584c3876a229ec9dae42410db35d21c1e0b25fd84ef6872372261556cdfa6613" }, + { "path": "src/lib.rs", "source_sha256": "761c153c3b5c449569ff85c571344b9252ea64f7f0b0424fb4819041b03d13c6", "source_git_blob": null, "sha256": "c7b8f90ca37f5125ec56d1f3be827adcab2fe1cf8d0f8341add17903837df087" }, { "path": "src/num.rs", "source_sha256": "39ff85da50c500ce91cf6dea81aedc0dcca1db5e7d0506696dde2da118e93a2a", "source_git_blob": null, "sha256": "39ff85da50c500ce91cf6dea81aedc0dcca1db5e7d0506696dde2da118e93a2a" }, { "path": "src/order.rs", "source_sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596", "source_git_blob": null, "sha256": "7e5b04eae8af134abb032e995f1d3c2ac473822923dfee8d463d9ade6ffeb596" }, { "path": "src/perturbation.rs", "source_sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5", "source_git_blob": null, "sha256": "fa274a822bbdf65f8e53e403eef78034dd87964b3f1d3134a064df4ec8cef9c5" }, { "path": "src/position.rs", "source_sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0", "source_git_blob": null, "sha256": "dfa70840805ecccf5b7eb6122921e46ca60c24cb7b3c17f3b55ffc2549368ab0" }, - { "path": "src/segments.rs", "source_sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc", "source_git_blob": null, "sha256": "8c0e51917e5cfb4f246218a241df88705e536806123c177fe47fb5790423d2a1" }, + { "path": "src/segments.rs", "source_sha256": "379f9455120492d237cb5a62b3fc06da018a72e2eb75bbfcd61b4cce501d9bbc", "source_git_blob": null, "sha256": "74478b647c0243a18bf0e34af28735544754b42445910cd4145aa1c31826d24d" }, { "path": "src/snapshots/linesweeper__tests__empty_horizontals.snap", "source_sha256": "e319881853e889badf6524f19af4cd6f112e8dd71bdc516826f4463134a82244", "source_git_blob": null, "sha256": "e319881853e889badf6524f19af4cd6f112e8dd71bdc516826f4463134a82244" }, { "path": "src/snapshots/linesweeper__tests__two_squares.snap", "source_sha256": "01961e0311a5af3b8f13eb52a2a7112560c47cf86771c04e40475dc6f15a0846", "source_git_blob": null, "sha256": "01961e0311a5af3b8f13eb52a2a7112560c47cf86771c04e40475dc6f15a0846" }, { "path": "src/snapshots/linesweeper__topology__tests__diamond.snap", "source_sha256": "cfaefd620a0a3d1376861bca09cd7c658ef00a32635b88f1b259a9b39cd15502", "source_git_blob": null, "sha256": "cfaefd620a0a3d1376861bca09cd7c658ef00a32635b88f1b259a9b39cd15502" },