-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
// FILE HEADER
-#include "text-view-word-processor.h"
+#include <dali-toolkit/internal/controls/text-view/text-view-word-processor.h>
// INTERNAL INCLUDES
-#include <dali/dali.h>
-#include "text-view-processor-helper-functions.h"
-#include "text-view-processor-dbg.h"
+#include <dali-toolkit/internal/controls/text-view/text-view-processor-helper-functions.h>
+#include <dali-toolkit/internal/controls/text-view/text-view-processor-dbg.h>
namespace Dali
{
namespace
{
+const std::string EMOJI_FONT_NAME( "SamsungEmoji" ); // Emoticons font family name.
+
/**
* Updates the word size and ascender.
*
}
void CreateWordTextInfo( const MarkupProcessor::StyledTextArray& word,
- TextViewProcessor::WordLayoutInfo& wordLayoutInfo )
+ WordLayoutInfo& wordLayoutInfo )
{
DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, "-->TextViewProcessor::CreateWordTextInfo\n" );
// Split in characters.
Character character = styledText.mText[index];
styledCharacter.mText.Append( character );
- //Choose the right font for the given character and style.
- ChooseFontFamilyName( styledCharacter );
-
- const Font font = Font::New( FontParameters( styledCharacter.mStyle.GetFontName(), styledCharacter.mStyle.GetFontStyle(), styledCharacter.mStyle.GetFontPointSize() ) );
- const Font::Metrics metrics = font.GetMetrics( character );
- const float ascender = font.GetAscender();
-
// Create layout character info.
CharacterLayoutInfo characterLayoutInfo;
characterLayoutInfo.mIsColorGlyph = GlyphImage::IsColorGlyph( character );
DALI_LOG_INFO( gTextViewProcessorLogFilter, Debug::General, " Is color glyph: %s\n", ( characterLayoutInfo.mIsColorGlyph ? "True" : "False" ) );
+ if( characterLayoutInfo.mIsColorGlyph )
+ {
+ styledCharacter.mStyle.SetFontName( EMOJI_FONT_NAME );
+ }
+ else
+ {
+ //Choose the right font for the given character and style.
+ ChooseFontFamilyName( styledCharacter );
+ }
+
+ const Font font = Font::New( FontParameters( styledCharacter.mStyle.GetFontName(), styledCharacter.mStyle.GetFontStyle(), styledCharacter.mStyle.GetFontPointSize() ) );
+ const Font::Metrics metrics = font.GetMetrics( character );
+ const float ascender = font.GetAscender();
+
// Fill Natural size info for current character.
characterLayoutInfo.mHeight = font.GetLineHeight();
characterLayoutInfo.mAdvance = metrics.GetAdvance();
characterLayoutInfo.mSize.height = characterLayoutInfo.mHeight;
characterLayoutInfo.mAscender = ascender;
- if( styledCharacter.mStyle.GetUnderline() )
+ if( styledCharacter.mStyle.IsUnderlineEnabled() )
{
characterLayoutInfo.mUnderlineThickness = font.GetUnderlineThickness(); // Both thickness and position includes the
characterLayoutInfo.mUnderlinePosition = font.GetUnderlinePosition(); // vertical pad adjust used in effects like glow or shadow.
const std::size_t numberOfCharacters,
bool& mergeWords,
bool& mergeLines,
- TextViewProcessor::TextInfoIndices& textInfoIndicesBegin,
- TextViewProcessor::TextInfoIndices& textInfoIndicesEnd,
- TextViewProcessor::TextInfoIndices& textInfoMergeIndicesBegin,
- TextViewProcessor::TextInfoIndices& textInfoMergeIndicesEnd,
- TextViewProcessor::WordGroupLayoutInfo& groupLayout,
+ TextInfoIndices& textInfoIndicesBegin,
+ TextInfoIndices& textInfoIndicesEnd,
+ TextInfoIndices& textInfoMergeIndicesBegin,
+ TextInfoIndices& textInfoMergeIndicesEnd,
+ LineLayoutInfo& lineLayout,
std::vector<TextActor>& removedTextActors )
{
- const TextViewProcessor::TextLayoutInfo& textLayoutInfo = relayoutData.mTextLayoutInfo;
+ const TextLayoutInfo& textLayoutInfo = relayoutData.mTextLayoutInfo;
// Get the word.
- WordLayoutInfo& wordLayout( *( groupLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex ) );
+ WordLayoutInfo& wordLayout( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex ) );
- if( TextViewProcessor::LineSeparator == wordLayout.mType )
+ if( LineSeparator == wordLayout.mType )
{
// If the word is a line separator and there is more lines, then current line and the line after need to be merged.
if( textInfoIndicesBegin.mLineIndex + 1 < textLayoutInfo.mLinesLayoutInfo.size() )
{
// If the word is a word separator. Check if the word before and the word after can be merged.
- if( ( 0 < textInfoIndicesBegin.mWordIndex ) && ( groupLayout.mWordsLayoutInfo.size() > textInfoIndicesBegin.mWordIndex + 1 ) )
+ if( ( 0 < textInfoIndicesBegin.mWordIndex ) && ( lineLayout.mWordsLayoutInfo.size() > textInfoIndicesBegin.mWordIndex + 1 ) )
{
- const WordLayoutInfo& wordLayoutBefore( *( groupLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex - 1 ) );
- const WordLayoutInfo& wordLayoutAfter( *( groupLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex + 1 ) );
+ const WordLayoutInfo& wordLayoutBefore( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex - 1 ) );
+ const WordLayoutInfo& wordLayoutAfter( *( lineLayout.mWordsLayoutInfo.begin() + textInfoIndicesBegin.mWordIndex + 1 ) );
if( ( NoSeparator == wordLayoutBefore.mType ) && ( NoSeparator == wordLayoutAfter.mType ) )
{
- // This word is a word separator (white space) and is not the first word of the group nor the last one.
+ // This word is a word separator (white space) and is not the first word of the line nor the last one.
mergeWords = true;
// Set indices to merge the words.
}
}
-void CollectTextActorsFromWords( std::vector<TextActor>& textActors, const WordGroupLayoutInfo& group, const std::size_t wordIndexBegin, const std::size_t wordIndexEnd )
+void CollectTextActorsFromWords( std::vector<TextActor>& textActors, const LineLayoutInfo& line, const std::size_t wordIndexBegin, const std::size_t wordIndexEnd )
{
- for( WordLayoutInfoContainer::const_iterator wordIt = group.mWordsLayoutInfo.begin() + wordIndexBegin, wordEndIt = group.mWordsLayoutInfo.begin() + wordIndexEnd;
+ for( WordLayoutInfoContainer::const_iterator wordIt = line.mWordsLayoutInfo.begin() + wordIndexBegin, wordEndIt = line.mWordsLayoutInfo.begin() + wordIndexEnd;
wordIt != wordEndIt;
++wordIt )
{