TextSeparatorType GetTextSeparatorType( const Character& character )
{
- // returns if the given character is a line separator '\n', a word separator ' ' or if is not a separator (any other character).
- return ( character.IsNewLine() ? LineSeparator : ( character.IsWhiteSpace() ? WordSeparator : NoSeparator ) );
+ // returns if the given character is a paragraph separator '\n', a word separator ' ' or if is not a separator (any other character).
+ return ( character.IsNewLine() ? ParagraphSeparator : ( character.IsWhiteSpace() ? WordSeparator : NoSeparator ) );
}
-void ChooseFontFamilyName( MarkupProcessor::StyledText& text )
+void ChooseFontFamilyName( const Character& character, TextStyle& style )
{
DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, "-->TextViewProcessor::ChooseFontFamilyName\n" );
- DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, " input font name: [%s]\n", text.mStyle.GetFontName().c_str() );
+ DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, " input font name: [%s]\n", style.GetFontName().c_str() );
bool userDefinedFontFamilyName = false;
// First check if there is a font defined in the style and it supports the given text.
- if( !text.mStyle.GetFontName().empty() )
+ if( !style.GetFontName().empty() )
{
- const FontParameters fontParams( text.mStyle.GetFontName(), text.mStyle.GetFontStyle() , text.mStyle.GetFontPointSize() );
+ const FontParameters fontParams( style.GetFontName(), style.GetFontStyle() , style.GetFontPointSize() );
const Font font = Font::New( fontParams );
- if( !font.IsDefaultSystemFont() && font.AllGlyphsSupported( text.mText ) )
+ if( !font.IsDefaultSystemFont() && font.AllGlyphsSupported( character ) )
{
userDefinedFontFamilyName = true;
}
const Font defaultSystemFont = Font::New();
// At this point no font is set or doesn't support the given text.
- if( !defaultSystemFont.AllGlyphsSupported( text.mText ) )
+ if( !defaultSystemFont.AllGlyphsSupported( character ) )
{
// If the default system font doesn't support the given text,
// an appropiate font is selected.
- text.mStyle.SetFontName( Font::GetFamilyForText( text.mText ) );
+ style.SetFontName( Font::GetFamilyForText( character ) );
// @TODO Font::GetFamilyForText() should return font family and font style.
}
else
{
// All characters are supported with default font, so use it
- text.mStyle.SetFontName( "" );
+ style.SetFontName( "" );
}
}
- DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, " output font name: [%s]\n", text.mStyle.GetFontName().c_str() );
+ DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, " output font name: [%s]\n", style.GetFontName().c_str() );
DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, "<--TextViewProcessor::ChooseFontFamilyName\n" );
}
indices = TextInfoIndices();
// Early return.
- if( textLayoutInfo.mLinesLayoutInfo.empty() )
+ if( textLayoutInfo.mParagraphsLayoutInfo.empty() )
{
// Text is empty. All indices are 0.
return;
std::size_t currentIndex = 0u; // stores how many characters have been traversed (within the whole text).
- // Traverse all lines and words until global index is found.
+ // Traverse all paragraphs and words until global index is found.
bool found = false;
- for( LineLayoutInfoContainer::const_iterator lineIt = textLayoutInfo.mLinesLayoutInfo.begin(),
- lineEndIt = textLayoutInfo.mLinesLayoutInfo.end();
- ( !found ) && ( lineIt != lineEndIt );
- ++lineIt, ++indices.mLineIndex )
+ for( ParagraphLayoutInfoContainer::const_iterator paragraphIt = textLayoutInfo.mParagraphsLayoutInfo.begin(),
+ paragraphEndIt = textLayoutInfo.mParagraphsLayoutInfo.end();
+ ( !found ) && ( paragraphIt != paragraphEndIt );
+ ++paragraphIt, ++indices.mParagraphIndex )
{
- const LineLayoutInfo& lineLayoutInfo( *lineIt );
+ const ParagraphLayoutInfo& paragraphLayoutInfo( *paragraphIt );
+ std::size_t currentCharactersTraversed = currentIndex; // stores how many characters have been traversed until this paragraph.
- if( currentIndex + lineLayoutInfo.mNumberOfCharacters > index )
+ if( currentIndex + paragraphLayoutInfo.mNumberOfCharacters > index )
{
- // The character is in this line
- for( WordLayoutInfoContainer::const_iterator wordIt = lineLayoutInfo.mWordsLayoutInfo.begin(),
- wordEndIt = lineLayoutInfo.mWordsLayoutInfo.end();
+ // The character is in this paragraph
+ for( WordLayoutInfoContainer::const_iterator wordIt = paragraphLayoutInfo.mWordsLayoutInfo.begin(),
+ wordEndIt = paragraphLayoutInfo.mWordsLayoutInfo.end();
( !found ) && ( wordIt != wordEndIt );
++wordIt, ++indices.mWordIndex )
{
{
// The character is in this word
indices.mCharacterIndex = index - currentIndex;
+ indices.mCharacterParagraphIndex = index - currentCharactersTraversed;
found = true;
}
else
currentIndex += wordLayoutInfo.mCharactersLayoutInfo.size();
}
} // end words.
- if( !lineLayoutInfo.mWordsLayoutInfo.empty() )
+ if( !paragraphLayoutInfo.mWordsLayoutInfo.empty() )
{
--indices.mWordIndex;
}
}
else
{
- // check in the next line
- currentIndex += lineLayoutInfo.mNumberOfCharacters;
+ // check in the next paragraph
+ currentIndex += paragraphLayoutInfo.mNumberOfCharacters;
}
- } // end lines.
+ } // end paragraphs.
// Need to decrease indices as they have been increased in the last loop.
- if( !textLayoutInfo.mLinesLayoutInfo.empty() )
+ if( !textLayoutInfo.mParagraphsLayoutInfo.empty() )
{
- --indices.mLineIndex;
+ --indices.mParagraphIndex;
}
}