@@ -1429,13 +1429,17 @@ fn smooth_anchors<V: MapVectorItems + Send>(
14291429 }
14301430 }
14311431
1432- // If spread is 0, remove handles for this point, making it a sharp corner
1432+ // If spread is 0, remove handles for this point, making it a sharp corner, unless the existing handles are preserved
14331433 if spread == 0. {
1434- new_manipulators_list. push ( ManipulatorGroup {
1435- anchor : current. anchor ,
1436- in_handle : None ,
1437- out_handle : None ,
1438- id : current. id ,
1434+ new_manipulators_list. push ( if preserve_existing {
1435+ * current
1436+ } else {
1437+ ManipulatorGroup {
1438+ anchor : current. anchor ,
1439+ in_handle : None ,
1440+ out_handle : None ,
1441+ id : current. id ,
1442+ }
14391443 } ) ;
14401444 continue ;
14411445 }
@@ -4607,6 +4611,23 @@ mod test {
46074611 ) ;
46084612 }
46094613
4614+ // Spreading by nothing is a no-op when the source's handles are preserved, so its curves keep their type and shape
4615+ #[ test]
4616+ fn smooth_anchors_spread_of_zero_keeps_the_source_curves ( ) {
4617+ let mut bezpath = BezPath :: new ( ) ;
4618+ bezpath. move_to ( ( 0. , 0. ) ) ;
4619+ bezpath. curve_to ( ( 50. , 0. ) , ( 100. , 0. ) , ( 100. , 0. ) ) ;
4620+ bezpath. curve_to ( ( 100. , 0. ) , ( 75. , 100. ) , ( 50. , 100. ) ) ;
4621+ bezpath. curve_to ( ( 25. , 100. ) , ( 0. , 0. ) , ( 0. , 0. ) ) ;
4622+ bezpath. close_path ( ) ;
4623+
4624+ let source = vector_item_from_bezpath ( bezpath) ;
4625+ let output = super :: smooth_anchors ( ( ) , source. clone ( ) , item ( 0. ) , item ( true ) ) ;
4626+
4627+ let segments = |item : & Item < Vector > | item. element ( ) . segment_iter ( item_paths ( item) ) . map ( |( _, segment, ..) | segment) . collect :: < Vec < _ > > ( ) ;
4628+ assert_eq ! ( segments( & output) , segments( & source) ) ;
4629+ }
4630+
46104631 // A loop of one segment has no neighbor to share a tangent with, so it passes through unchanged
46114632 #[ test]
46124633 fn smooth_anchors_keeps_a_single_segment_loop ( ) {
0 commit comments