File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ let TEMP_CANVAS = null;
25
25
26
26
const RADIAN = Math . PI / 180 ;
27
27
const textOffsetY = 1 ;
28
+ const TEXT_BASELINE = 'top' ;
28
29
29
30
const Canvas = {
30
31
getCanvas2DContext ( canvas ) {
@@ -48,13 +49,21 @@ const Canvas = {
48
49
} ,
49
50
50
51
prepareCanvasFont ( ctx , style ) {
51
- ctx . textBaseline = 'top' ;
52
- ctx . font = getFont ( style ) ;
52
+ if ( ctx . textBaseline !== TEXT_BASELINE ) {
53
+ ctx . textBaseline = TEXT_BASELINE ;
54
+ }
55
+ const font = getFont ( style ) ;
56
+ if ( ctx . font !== font ) {
57
+ ctx . font = font ;
58
+ }
53
59
let fill = style [ 'textFill' ] ;
54
60
if ( ! fill ) {
55
61
fill = DEFAULT_TEXT_COLOR ;
56
62
}
57
- ctx . fillStyle = Canvas . getRgba ( fill , style [ 'textOpacity' ] ) ;
63
+ const fillStyle = Canvas . getRgba ( fill , style [ 'textOpacity' ] ) ;
64
+ if ( ctx . fillStyle !== fillStyle ) {
65
+ ctx . fillStyle = fillStyle ;
66
+ }
58
67
} ,
59
68
60
69
/**
You can’t perform that action at this time.
0 commit comments