2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/segmentation.h>
22 #include <dali/devel-api/text-abstraction/segmentation.h>
25 #include <dali/integration-api/debug.h>
30 #include <dali-toolkit/internal/text/character-set-conversion.h>
36 #if defined(DEBUG_ENABLED)
37 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_SEGMENTATION");
52 void SetLineBreakInfo( const Vector<Character>& text,
53 Vector<LineBreakInfo>& lineBreakInfo )
55 const Length numberOfCharacters = text.Count();
57 if( 0u == numberOfCharacters )
59 // Nothing to do if there are no characters.
63 // Retrieve the line break info.
64 lineBreakInfo.Resize( numberOfCharacters );
65 TextAbstraction::Segmentation::Get().GetLineBreakPositions( text.Begin(),
67 lineBreakInfo.Begin() );
69 if( gLogFilter->IsEnabledFor(Debug::Verbose) )
72 Utf32ToUtf8( text.Begin(), numberOfCharacters, utf8 );
75 info.reserve( numberOfCharacters );
76 for( unsigned int i=0; i<lineBreakInfo.Count(); ++i )
78 info.push_back( static_cast<char>('0' + lineBreakInfo[i]) );
81 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SetLineBreakInfo Characters: %s\n", utf8.c_str() );
82 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SetLineBreakInfo Break info: %s\n", info.c_str() );
87 void ReplaceLineBreakInfo( LogicalModel& model,
88 CharacterIndex characterIndex,
89 Length numberOfCharactersToRemove,
90 Length numberOfCharactersToInsert )
94 void SetWordBreakInfo( const Vector<Character>& text,
95 Vector<WordBreakInfo>& wordBreakInfo )
97 const Length numberOfCharacters = text.Count();
99 if( 0u == numberOfCharacters )
101 // Nothing to do if there are no characters.
105 // Retrieve the word break info.
106 wordBreakInfo.Resize( numberOfCharacters );
107 TextAbstraction::Segmentation::Get().GetWordBreakPositions( text.Begin(),
109 wordBreakInfo.Begin() );
111 if( gLogFilter->IsEnabledFor(Debug::Verbose) )
114 Utf32ToUtf8( text.Begin(), numberOfCharacters, utf8 );
117 info.reserve( numberOfCharacters );
118 for( unsigned int i=0; i<wordBreakInfo.Count(); ++i )
120 info.push_back( static_cast<char>('0' + wordBreakInfo[i]) );
123 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SetWordBreakInfo Characters: %s\n", utf8.c_str() );
124 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "SetWordBreakInfo Break info: %s\n", info.c_str() );
129 void ReplaceWordBreakInfo( LogicalModel& model,
130 CharacterIndex characterIndex,
131 Length numberOfCharactersToRemove,
132 Length numberOfCharactersToInsert )
138 } // namespace Toolkit