Skip to content

Commit

Permalink
Allow empty sub-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
lsalzman committed Jun 19, 2023
1 parent fa2de1c commit 112a214
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/aarasterizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,13 +1033,15 @@ fn ValidatePathTypes(typesArray: &[BYTE], mut count: INT) -> bool {
// Advance to the first point after the 'start' point:
count -= 1;
if (count == 0) {
TraceTag!((tagMILWarning, "Path ended after start-path"));
return (false);
//TraceTag!((tagMILWarning, "Path ended after start-path"));
//return (false);
return (true);
}

if ((types[1] & PathPointTypePathTypeMask) == PathPointTypeStart) {
TraceTag!((tagMILWarning, "Can't have a start followed by a start!"));
return (false);
//TraceTag!((tagMILWarning, "Can't have a start followed by a start!"));
//return (false);
return (true);
}

// Process runs of lines and Bezier curves:
Expand Down
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,4 +676,17 @@ mod tests {
assert_eq!(result.len(), 279);
assert_eq!(calculate_hash(&rasterize_to_mask(&result, 70, 40)), 0xbd2eec3cfe9bd30b);
}

#[test]
fn close_after_move_to() {
let mut p = PathBuilder::new();
p.move_to(0., 0.);
p.line_to(0., 10.);
p.line_to(10., 10.);
p.move_to(10., 0.);
p.close();
let result = p.rasterize_to_tri_list(0, 0, 20, 20);
assert_eq!(result.len(), 27);
assert_eq!(dbg!(calculate_hash(&result)), 0xecfdf5bdfa25a1dd);
}
}

0 comments on commit 112a214

Please sign in to comment.