- for( CharacterLayoutInfoContainer::iterator characterIt = word.mCharactersLayoutInfo.begin(), characterEndIt = word.mCharactersLayoutInfo.end();
- characterIt != characterEndIt;
- ++characterIt )
- {
- CharacterLayoutInfo& characterLayout( *characterIt );
-
- // Check if there is a new line.
- const bool newLine = !lineLayoutEnd && ( characterGlobalIndex == relayoutData.mLines[lineLayoutInfoIndex].mCharacterGlobalIndex );
-
- if( newLine )
- {
- // Point to the next line.
- ++lineLayoutInfoIndex;
- if( lineLayoutInfoIndex >= lineLayoutInfoSize )
- {
- // Arrived at last line.
- lineLayoutEnd = true; // Avoids access out of bounds in the relayoutData.mLines vector.
- }
- glyphActorCreatedForLine = false;
- }
-
- if( !characterLayout.mStyledText.mText.IsEmpty() )
- {
- // Do not create a glyph-actor if there is no text.
- const Character character = characterLayout.mStyledText.mText[0]; // there are only one character per character layout.
-
- if( characterLayout.mIsColorGlyph ||
- !character.IsWhiteSpace() || // A new line character is also a white space.
- ( character.IsWhiteSpace() && characterLayout.mStyledText.mStyle.IsUnderlineEnabled() ) )
- {
- // Do not create a glyph-actor if it's a white space (without underline) or a new line character.
-
- // Creates one glyph-actor per each counsecutive group of characters, with the same style, per line, or if it's an emoticon.
-
- if( !glyphActorCreatedForLine ||
- characterLayout.mIsColorGlyph ||
- ( characterLayout.mStyledText.mStyle != currentStyle ) ||
- ( characterLayout.mGradientColor != currentGradientColor ) ||
- ( characterLayout.mStartPoint != currentStartPoint ) ||
- ( characterLayout.mEndPoint != currentEndPoint ) ||
- ( characterLayout.mIsColorGlyph != currentIsColorGlyph ) )
- {
- characterLayout.mSetText = false;
- characterLayout.mSetStyle = false;
-
- // There is a new style or a new line.
- glyphActorCreatedForLine = true;
-
- if( characterLayout.mIsColorGlyph )
- {
- ImageActor imageActor = ImageActor::DownCast( characterLayout.mGlyphActor );
- if( !imageActor )
- {
- characterLayout.mGlyphActor = ImageActor::New();
- characterLayout.mSetText = true;
- }
- }
- else
- {
- TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
-
- if( textActor )
- {
- // Try to reuse first the text-actor of this character.
- textActor.SetTextStyle( characterLayout.mStyledText.mStyle );
- currentGlyphActor = textActor;
- }
- else
- {
- // If there is no text-actor, try to retrieve one from the cache.
- textActor = relayoutData.mTextActorCache.RetrieveTextActor();
-
- // If still there is no text-actor, create one.
- if( !textActor )
- {
- TextActorParameters parameters( characterLayout.mStyledText.mStyle, TextActorParameters::FONT_DETECTION_OFF );
- textActor = TextActor::New( NULL, parameters );
- }
- else
- {
- textActor.SetTextStyle( characterLayout.mStyledText.mStyle );
- }
-
- currentGlyphActor = textActor;
- }
- characterLayout.mGlyphActor = currentGlyphActor;
- }
-
- // Update style to be checked with next characters.
- currentStyle = characterLayout.mStyledText.mStyle;
- currentGradientColor = characterLayout.mGradientColor;
- currentStartPoint = characterLayout.mStartPoint;
- currentEndPoint = characterLayout.mEndPoint;
- currentIsColorGlyph = characterLayout.mIsColorGlyph;
-
- characterLayout.mGlyphActor.SetParentOrigin( ParentOrigin::TOP_LEFT );
- characterLayout.mGlyphActor.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT );
- }
- else
- {
- DALI_ASSERT_DEBUG( !characterLayout.mIsColorGlyph && "TextViewProcessor::InitializeTextActorInfo. An image-actor doesn't store more than one emoticon." );
-
- // Same style than previous one.
- TextActor textActor = TextActor::DownCast( characterLayout.mGlyphActor );
- if( textActor )
- {
- // There is a previously created text-actor for this character.
- // If this character has another one put it into the cache.
- textActor.SetText( "" );
- textActorsToRemove.push_back( textActor );
- }
-
- if( characterLayout.mGlyphActor )
- {
- characterLayout.mGlyphActor.Reset();
- }
- }
- } // no white space / new line char
- } // text not empty
-
- ++characterGlobalIndex;
- } // characters
- } // words
- } // groups
- } // lines
-
- // Insert the spare text-actors into the cache.
- relayoutData.mTextActorCache.InsertTextActors( textActorsToRemove );