@@ -830,6 +830,9 @@ export class Paint implements IPaint {
830
830
}
831
831
public setFilterBitmap ( param0 : boolean ) { }
832
832
public setTypeface ( font : Font | UIFont ) : Font {
833
+ if ( this . font === font ) {
834
+ return this . _font ;
835
+ }
833
836
if ( font instanceof Font ) {
834
837
this . _font = font ;
835
838
} else if ( font ) {
@@ -963,7 +966,11 @@ export class Paint implements IPaint {
963
966
// this.font = Font.default;
964
967
}
965
968
setFont ( font : Font ) {
969
+ if ( font === this . _font ) {
970
+ return ;
971
+ }
966
972
this . _font = font ;
973
+ this . _textAttribs = null ;
967
974
}
968
975
getFont ( ) {
969
976
if ( ! this . _font ) {
@@ -979,6 +986,9 @@ export class Paint implements IPaint {
979
986
}
980
987
981
988
setFontFamily ( familyName : string ) {
989
+ if ( this . _font && this . _font . fontFamily === familyName ) {
990
+ return ;
991
+ }
982
992
this . _font = this . font . withFontFamily ( familyName ) ;
983
993
this . _textAttribs = null ;
984
994
}
@@ -993,6 +1003,9 @@ export class Paint implements IPaint {
993
1003
}
994
1004
995
1005
set fontWeight ( weight : FontWeight ) {
1006
+ if ( this . _font && this . _font . fontWeight === weight ) {
1007
+ return ;
1008
+ }
996
1009
this . setFontWeight ( weight ) ;
997
1010
}
998
1011
setFontWeight ( weight : FontWeight ) {
@@ -1003,6 +1016,9 @@ export class Paint implements IPaint {
1003
1016
this . setFontStyle ( style ) ;
1004
1017
}
1005
1018
setFontStyle ( style : FontStyle ) {
1019
+ if ( this . _font && this . _font . fontStyle === style ) {
1020
+ return ;
1021
+ }
1006
1022
this . _font = this . font . withFontStyle ( style ) ;
1007
1023
this . _textAttribs = null ;
1008
1024
}
@@ -1025,6 +1041,9 @@ export class Paint implements IPaint {
1025
1041
return this . getTextSize ( ) ;
1026
1042
}
1027
1043
setTextSize ( textSize ) {
1044
+ if ( this . _font && this . _font . fontSize === textSize ) {
1045
+ return ;
1046
+ }
1028
1047
this . _font = this . font . withFontSize ( textSize ) ;
1029
1048
this . _textAttribs = null ;
1030
1049
}
0 commit comments