@@ -49,7 +49,6 @@ function TextElement(element) {
49
49
// public
50
50
this . _text = "" ; // the original user-defined text
51
51
this . _symbols = [ ] ; // array of symbols with unicode processing and markup removed
52
- this . _visibleSymbols = [ ] ; // array of symbols that is visible to the user
53
52
this . _colorPalette = [ ] ; // per-symbol color palette
54
53
this . _symbolColors = null ; // per-symbol color indexes. only set for text with markup.
55
54
this . _i18nKey = null ;
@@ -156,7 +155,7 @@ var NON_VISIBLE_CHAR = new Set([
156
155
'\u202D' , // left-to-right override
157
156
'\u202E' , // right-to-left override
158
157
'\u202C' , // pop directional formatting
159
- '\u2069' , // pop directional isolate
158
+ '\u2069' // pop directional isolate
160
159
] ) ;
161
160
162
161
Object . assign ( TextElement . prototype , {
@@ -506,13 +505,17 @@ Object.assign(TextElement.prototype, {
506
505
this . _element . addModelToLayers ( this . _model ) ;
507
506
}
508
507
509
- this . _visibleSymbols . length = 0 ;
508
+ // Remove the non visible symbols
509
+ var inputIndex = 0 ;
510
510
for ( i = 0 ; i < this . _symbols . length ; i ++ ) {
511
511
if ( ! NON_VISIBLE_CHAR . has ( this . _symbols [ i ] ) ) {
512
- this . _visibleSymbols . push ( this . _symbols [ i ] ) ;
512
+ this . _symbols [ inputIndex ] = this . _symbols [ i ] ;
513
+ inputIndex ++ ;
513
514
}
514
515
}
515
516
517
+ this . _symbols . length = inputIndex ;
518
+
516
519
this . _updateMeshes ( ) ;
517
520
518
521
// update render range
@@ -590,7 +593,7 @@ Object.assign(TextElement.prototype, {
590
593
}
591
594
592
595
var MAGIC = 32 ;
593
- var l = this . _visibleSymbols . length ;
596
+ var l = this . _symbols . length ;
594
597
var _x = 0 ; // cursors
595
598
var _y = 0 ;
596
599
var _z = 0 ;
@@ -701,7 +704,7 @@ Object.assign(TextElement.prototype, {
701
704
// In right-to-left mode we loop through the symbols from end to the beginning
702
705
// in order to wrap lines in the correct order
703
706
for ( i = 0 ; i < l ; i ++ ) {
704
- char = this . _visibleSymbols [ i ] ;
707
+ char = this . _symbols [ i ] ;
705
708
706
709
var x = 0 ;
707
710
var y = 0 ;
@@ -728,9 +731,9 @@ Object.assign(TextElement.prototype, {
728
731
if ( numCharsThisLine > 0 ) {
729
732
var kernTable = this . _font . data . kerning ;
730
733
if ( kernTable ) {
731
- var kernLeft = kernTable [ string . getCodePoint ( this . _visibleSymbols [ i - 1 ] ) || 0 ] ;
734
+ var kernLeft = kernTable [ string . getCodePoint ( this . _symbols [ i - 1 ] ) || 0 ] ;
732
735
if ( kernLeft ) {
733
- kerning = kernLeft [ string . getCodePoint ( this . _visibleSymbols [ i ] ) || 0 ] || 0 ;
736
+ kerning = kernLeft [ string . getCodePoint ( this . _symbols [ i ] ) || 0 ] || 0 ;
734
737
}
735
738
}
736
739
}
@@ -749,7 +752,7 @@ Object.assign(TextElement.prototype, {
749
752
if ( isLineBreak ) {
750
753
numBreaksThisLine ++ ;
751
754
if ( this . _maxLines < 0 || lines < this . _maxLines ) {
752
- breakLine ( this . _visibleSymbols , i , _xMinusTrailingWhitespace ) ;
755
+ breakLine ( this . _symbols , i , _xMinusTrailingWhitespace ) ;
753
756
wordStartIndex = i + 1 ;
754
757
lineStartIndex = i + 1 ;
755
758
}
@@ -771,7 +774,7 @@ Object.assign(TextElement.prototype, {
771
774
// broken onto multiple lines.
772
775
if ( numWordsThisLine === 0 ) {
773
776
wordStartIndex = i ;
774
- breakLine ( this . _visibleSymbols , i , _xMinusTrailingWhitespace ) ;
777
+ breakLine ( this . _symbols , i , _xMinusTrailingWhitespace ) ;
775
778
} else {
776
779
// Move back to the beginning of the current word.
777
780
var backtrack = Math . max ( i - wordStartIndex , 0 ) ;
@@ -784,7 +787,7 @@ Object.assign(TextElement.prototype, {
784
787
var backtrackStart = wordStartIndex ;
785
788
var backtrackEnd = i ;
786
789
for ( j = backtrackStart ; j < backtrackEnd ; j ++ ) {
787
- var backChar = this . _visibleSymbols [ j ] ;
790
+ var backChar = this . _symbols [ j ] ;
788
791
var backCharData = json . chars [ backChar ] ;
789
792
var backMeshInfo = this . _meshInfo [ ( backCharData && backCharData . map ) || 0 ] ;
790
793
backMeshInfo . lines [ lines - 1 ] -= 1 ;
@@ -794,7 +797,7 @@ Object.assign(TextElement.prototype, {
794
797
795
798
i -= backtrack + 1 ;
796
799
797
- breakLine ( this . _visibleSymbols , wordStartIndex , wordStartX ) ;
800
+ breakLine ( this . _symbols , wordStartIndex , wordStartX ) ;
798
801
continue ;
799
802
}
800
803
}
@@ -933,7 +936,7 @@ Object.assign(TextElement.prototype, {
933
936
// there will almost always be some leftover text on the final line which has
934
937
// not yet been pushed to _lineContents.
935
938
if ( lineStartIndex < l ) {
936
- breakLine ( this . _visibleSymbols , l , _x ) ;
939
+ breakLine ( this . _symbols , l , _x ) ;
937
940
}
938
941
}
939
942
0 commit comments