@@ -17,7 +17,6 @@ import {
1717 DrawOPS ,
1818 FeatureTest ,
1919 FONT_IDENTITY_MATRIX ,
20- IDENTITY_MATRIX ,
2120 ImageKind ,
2221 info ,
2322 OPS ,
@@ -311,7 +310,7 @@ class CanvasExtraState {
311310
312311 fontSizeScale = 1 ;
313312
314- textMatrix = IDENTITY_MATRIX ;
313+ textMatrix = null ;
315314
316315 textMatrixScale = 1 ;
317316
@@ -1611,7 +1610,7 @@ class CanvasGraphics {
16111610
16121611 // Text
16131612 beginText ( ) {
1614- this . current . textMatrix = IDENTITY_MATRIX ;
1613+ this . current . textMatrix = null ;
16151614 this . current . textMatrixScale = 1 ;
16161615 this . current . x = this . current . lineX = 0 ;
16171616 this . current . y = this . current . lineY = 0 ;
@@ -1732,12 +1731,13 @@ class CanvasGraphics {
17321731 this . moveText ( x , y ) ;
17331732 }
17341733
1735- setTextMatrix ( a , b , c , d , e , f ) {
1736- this . current . textMatrix = [ a , b , c , d , e , f ] ;
1737- this . current . textMatrixScale = Math . hypot ( a , b ) ;
1734+ setTextMatrix ( matrix ) {
1735+ const { current } = this ;
1736+ current . textMatrix = matrix ;
1737+ current . textMatrixScale = Math . hypot ( matrix [ 0 ] , matrix [ 1 ] ) ;
17381738
1739- this . current . x = this . current . lineX = 0 ;
1740- this . current . y = this . current . lineY = 0 ;
1739+ current . x = current . lineX = 0 ;
1740+ current . y = current . lineY = 0 ;
17411741 }
17421742
17431743 nextLine ( ) {
@@ -1904,7 +1904,9 @@ class CanvasGraphics {
19041904 ! current . patternFill ;
19051905
19061906 ctx . save ( ) ;
1907- ctx . transform ( ...current . textMatrix ) ;
1907+ if ( current . textMatrix ) {
1908+ ctx . transform ( ...current . textMatrix ) ;
1909+ }
19081910 ctx . translate ( current . x , current . y + current . textRise ) ;
19091911
19101912 if ( fontDirection > 0 ) {
@@ -2099,7 +2101,9 @@ class CanvasGraphics {
20992101 this . _cachedGetSinglePixelWidth = null ;
21002102
21012103 ctx . save ( ) ;
2102- ctx . transform ( ...current . textMatrix ) ;
2104+ if ( current . textMatrix ) {
2105+ ctx . transform ( ...current . textMatrix ) ;
2106+ }
21032107 ctx . translate ( current . x , current . y + current . textRise ) ;
21042108
21052109 ctx . scale ( textHScale , fontDirection ) ;
0 commit comments