@@ -340,10 +340,14 @@ class CanvasExtraState {
340340 }
341341
342342 updateRectMinMax ( transform , rect ) {
343- const p1 = Util . applyTransform ( rect , transform ) ;
344- const p2 = Util . applyTransform ( rect . slice ( 2 ) , transform ) ;
345- const p3 = Util . applyTransform ( [ rect [ 0 ] , rect [ 3 ] ] , transform ) ;
346- const p4 = Util . applyTransform ( [ rect [ 2 ] , rect [ 1 ] ] , transform ) ;
343+ const p1 = [ rect [ 0 ] , rect [ 1 ] ] ;
344+ Util . applyTransform ( p1 , transform ) ;
345+ const p2 = [ rect [ 2 ] , rect [ 3 ] ] ;
346+ Util . applyTransform ( p2 , transform ) ;
347+ const p3 = [ rect [ 0 ] , rect [ 3 ] ] ;
348+ Util . applyTransform ( p3 , transform ) ;
349+ const p4 = [ rect [ 2 ] , rect [ 1 ] ] ;
350+ Util . applyTransform ( p4 , transform ) ;
347351
348352 this . minX = Math . min ( this . minX , p1 [ 0 ] , p2 [ 0 ] , p3 [ 0 ] , p4 [ 0 ] ) ;
349353 this . minY = Math . min ( this . minY , p1 [ 1 ] , p2 [ 1 ] , p3 [ 1 ] , p4 [ 1 ] ) ;
@@ -2111,8 +2115,9 @@ class CanvasGraphics {
21112115 this . restore ( ) ;
21122116 }
21132117
2114- const transformed = Util . applyTransform ( [ glyph . width , 0 ] , fontMatrix ) ;
2115- width = transformed [ 0 ] * fontSize + spacing ;
2118+ const p = [ glyph . width , 0 ] ;
2119+ Util . applyTransform ( p , fontMatrix ) ;
2120+ width = p [ 0 ] * fontSize + spacing ;
21162121
21172122 ctx . translate ( width , 0 ) ;
21182123 current . x += width * textHScale ;
@@ -2588,8 +2593,9 @@ class CanvasGraphics {
25882593 positions [ i + 1 ] ,
25892594 ] ) ;
25902595
2591- const [ x , y ] = Util . applyTransform ( [ 0 , 0 ] , trans ) ;
2592- ctx . drawImage ( mask . canvas , x , y ) ;
2596+ // Here we want to apply the transform at the origin,
2597+ // hence no additional computation is necessary.
2598+ ctx . drawImage ( mask . canvas , trans [ 4 ] , trans [ 5 ] ) ;
25932599 }
25942600 ctx . restore ( ) ;
25952601 this . compose ( ) ;
0 commit comments