@@ -37,7 +37,7 @@ function TextProperty(elem, data, dynamicProperties){
3737 yOffset : 0 ,
3838 __complete : false ,
3939 finalSize :0 ,
40- finalText :'' ,
40+ finalText :[ ] ,
4141 finalLineHeight : 0
4242
4343 } ;
@@ -106,14 +106,28 @@ TextProperty.prototype.getValue = function(_forceRender) {
106106 this . completeTextData ( textDocumentData ) ;
107107 }
108108 this . setCurrentData ( textDocumentData ) ;
109- //TODO check this
110109 this . _mdf = ! this . _isFirstFrame ;
111110 this . pv = this . v = this . currentData . t ;
112111 this . keysIndex = i ;
113112 }
114113 this . _frameId = frameId ;
115114} ;
116115
116+ TextProperty . prototype . buildFinalText = function ( text ) {
117+ var combinedCharacters = FontManager . getCombinedCharacterCodes ( ) ;
118+ var charactersArray = [ ] ;
119+ var i = 0 , len = text . length ;
120+ while ( i < len ) {
121+ if ( combinedCharacters . indexOf ( text . charCodeAt ( i ) ) !== - 1 ) {
122+ charactersArray [ charactersArray . length - 1 ] += text . charAt ( i ) ;
123+ } else {
124+ charactersArray . push ( text . charAt ( i ) ) ;
125+ }
126+ i += 1 ;
127+ }
128+ return charactersArray ;
129+ }
130+
117131TextProperty . prototype . completeTextData = function ( documentData ) {
118132 documentData . __complete = true ;
119133 var fontManager = this . elem . globalData . fontManager ;
@@ -162,7 +176,7 @@ TextProperty.prototype.completeTextData = function(documentData) {
162176 documentData . fStyle = fStyle ;
163177 len = documentData . t . length ;
164178 documentData . finalSize = documentData . s ;
165- documentData . finalText = documentData . t ;
179+ documentData . finalText = this . buildFinalText ( documentData . t ) ;
166180 documentData . finalLineHeight = documentData . lh ;
167181 var trackingOffset = documentData . tr / 1000 * documentData . finalSize ;
168182 if ( documentData . sz ) {
@@ -171,36 +185,37 @@ TextProperty.prototype.completeTextData = function(documentData) {
171185 var boxHeight = documentData . sz [ 1 ] ;
172186 var currentHeight , finalText ;
173187 while ( flag ) {
174- finalText = documentData . t ;
188+ finalText = this . buildFinalText ( documentData . t ) ;
175189 currentHeight = 0 ;
176190 lineWidth = 0 ;
177- len = documentData . t . length ;
191+ len = finalText . length ;
178192 trackingOffset = documentData . tr / 1000 * documentData . finalSize ;
179193 var lastSpaceIndex = - 1 ;
180194 for ( i = 0 ; i < len ; i += 1 ) {
181195 newLineFlag = false ;
182- if ( finalText . charAt ( i ) === ' ' ) {
196+ if ( finalText [ i ] === ' ' ) {
183197 lastSpaceIndex = i ;
184- } else if ( finalText . charCodeAt ( i ) === 13 ) {
198+ } else if ( finalText [ i ] . charCodeAt ( 0 ) === 13 ) {
185199 lineWidth = 0 ;
186200 newLineFlag = true ;
187201 currentHeight += documentData . finalLineHeight || documentData . finalSize * 1.2 ;
188202 }
189203 if ( fontManager . chars ) {
190- charData = fontManager . getCharData ( finalText . charAt ( i ) , fontData . fStyle , fontData . fFamily ) ;
204+ charData = fontManager . getCharData ( finalText [ i ] , fontData . fStyle , fontData . fFamily ) ;
191205 cLength = newLineFlag ? 0 : charData . w * documentData . finalSize / 100 ;
192206 } else {
193207 //tCanvasHelper.font = documentData.s + 'px '+ fontData.fFamily;
194- cLength = fontManager . measureText ( finalText . charAt ( i ) , documentData . f , documentData . finalSize ) ;
208+ cLength = fontManager . measureText ( finalText [ i ] , documentData . f , documentData . finalSize ) ;
195209 }
196- if ( lineWidth + cLength > boxWidth && finalText . charAt ( i ) !== ' ' ) {
210+ if ( lineWidth + cLength > boxWidth && finalText [ i ] !== ' ' ) {
197211 if ( lastSpaceIndex === - 1 ) {
198212 len += 1 ;
199213 } else {
200214 i = lastSpaceIndex ;
201215 }
202216 currentHeight += documentData . finalLineHeight || documentData . finalSize * 1.2 ;
203- finalText = finalText . substr ( 0 , i ) + "\r" + finalText . substr ( i === lastSpaceIndex ? i + 1 : i ) ;
217+ finalText . splice ( i , lastSpaceIndex === i ? 1 : 0 , "\r" ) ;
218+ //finalText = finalText.substr(0,i) + "\r" + finalText.substr(i === lastSpaceIndex ? i + 1 : i);
204219 lastSpaceIndex = - 1 ;
205220 lineWidth = 0 ;
206221 } else {
@@ -226,7 +241,7 @@ TextProperty.prototype.completeTextData = function(documentData) {
226241 var currentChar ;
227242 for ( i = 0 ; i < len ; i += 1 ) {
228243 newLineFlag = false ;
229- currentChar = documentData . finalText . charAt ( i ) ;
244+ currentChar = documentData . finalText [ i ] ;
230245 if ( currentChar === ' ' ) {
231246 val = '\u00A0' ;
232247 } else if ( currentChar . charCodeAt ( 0 ) === 13 ) {
@@ -238,7 +253,7 @@ TextProperty.prototype.completeTextData = function(documentData) {
238253 newLineFlag = true ;
239254 currentLine += 1 ;
240255 } else {
241- val = documentData . finalText . charAt ( i ) ;
256+ val = documentData . finalText [ i ] ;
242257 }
243258 if ( fontManager . chars ) {
244259 charData = fontManager . getCharData ( currentChar , fontData . fStyle , fontManager . getFontByName ( documentData . f ) . fFamily ) ;
0 commit comments