Bump linesweeper to 0.4 (#4273)

* Bump linesweeper to 0.4

* Avoid crash if there's an indexing bug

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
jneem
2026-06-23 01:15:55 +01:00
committed by GitHub
parent 1158d93bb4
commit 57ee2b00ca
3 changed files with 15 additions and 7 deletions

View File

@@ -77,6 +77,17 @@ impl linesweeper::topology::WindingNumber for WindingNumber {
elems[tag] = if positive { 1 } else { -1 };
Self { elems }
}
fn of_tag(&self, (tag, out_of): Self::Tag) -> Self {
let mut elems = SmallVec::with_capacity(out_of);
elems.resize(out_of, 0);
if let (Some(slot), Some(&value)) = (elems.get_mut(tag), self.elems.get(tag)) {
*slot = value;
} else {
log::warn!("WindingNumber::of_tag: tag {tag} out of bounds (out_of {out_of}, len {})", self.elems.len());
}
Self { elems }
}
}
impl std::ops::AddAssign for WindingNumber {
@@ -162,11 +173,8 @@ fn boolean_operation_on_vector_list(vector: &List<Vector>, boolean_operation: Bo
}
};
let contours = top.contours(|winding| winding.is_inside(boolean_operation));
// TODO: Linesweeper emits contours in the opposite winding direction from the rest of Kurbo's and Graphite's vector graphics system (clockwise in screen coordinates).
// TODO: Report this upstream to Linesweeper and remove this `.reverse()` workaround once fixed.
for subpath in from_bez_paths(contours.contours().map(|c| &c.path)) {
row.element_mut().append_subpath(subpath.reverse(), false);
row.element_mut().append_subpath(subpath, false);
}
list.push(row);