@@ -1768,7 +1768,6 @@ class CanvasGraphics {
17681768 const paths = this . pendingTextPaths ;
17691769 const ctx = this . ctx ;
17701770 if ( paths === undefined ) {
1771- ctx . beginPath ( ) ;
17721771 return ;
17731772 }
17741773
@@ -1785,7 +1784,6 @@ class CanvasGraphics {
17851784 }
17861785
17871786 ctx . clip ( newPath ) ;
1788- ctx . beginPath ( ) ;
17891787 delete this . pendingTextPaths ;
17901788 }
17911789
@@ -2292,8 +2290,9 @@ class CanvasGraphics {
22922290 }
22932291
22942292 setCharWidthAndBounds ( xWidth , yWidth , llx , lly , urx , ury ) {
2295- this . ctx . rect ( llx , lly , urx - llx , ury - lly ) ;
2296- this . ctx . clip ( ) ;
2293+ const clip = new Path2D ( ) ;
2294+ clip . rect ( llx , lly , urx - llx , ury - lly ) ;
2295+ this . ctx . clip ( clip ) ;
22972296 this . endPath ( ) ;
22982297 }
22992298
@@ -2436,11 +2435,11 @@ class CanvasGraphics {
24362435 this . baseTransform = getCurrentTransform ( this . ctx ) ;
24372436
24382437 if ( bbox ) {
2439- const width = bbox [ 2 ] - bbox [ 0 ] ;
2440- const height = bbox [ 3 ] - bbox [ 1 ] ;
2441- this . ctx . rect ( bbox [ 0 ] , bbox [ 1 ] , width , height ) ;
24422438 this . current . updateRectMinMax ( getCurrentTransform ( this . ctx ) , bbox ) ;
2443- this . clip ( ) ;
2439+ const [ x0 , y0 , x1 , y1 ] = bbox ;
2440+ const clip = new Path2D ( ) ;
2441+ clip . rect ( x0 , y0 , x1 - x0 , y1 - y0 ) ;
2442+ this . ctx . clip ( clip ) ;
24442443 this . endPath ( ) ;
24452444 }
24462445 }
@@ -2668,9 +2667,9 @@ class CanvasGraphics {
26682667 // Consume a potential path before clipping.
26692668 this . endPath ( ) ;
26702669
2671- this . ctx . rect ( rect [ 0 ] , rect [ 1 ] , width , height ) ;
2672- this . ctx . clip ( ) ;
2673- this . ctx . beginPath ( ) ;
2670+ const clip = new Path2D ( ) ;
2671+ clip . rect ( rect [ 0 ] , rect [ 1 ] , width , height ) ;
2672+ this . ctx . clip ( clip ) ;
26742673 }
26752674 }
26762675
@@ -3079,7 +3078,6 @@ class CanvasGraphics {
30793078 this . pendingClip = null ;
30803079 }
30813080 this . current . startNewPathAndClipBox ( this . current . clipBox ) ;
3082- ctx . beginPath ( ) ;
30833081 }
30843082
30853083 getSinglePixelWidth ( ) {
0 commit comments