2 * Copyright (c) 2017 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/multi-language-support-impl.h>
22 #include <dali/integration-api/debug.h>
23 #include <dali/devel-api/adaptor-framework/singleton-service.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
27 #include <dali-toolkit/internal/text/multi-language-helper-functions.h>
28 #include <dali-toolkit/devel-api/styling/style-manager-devel.h>
38 #if defined(DEBUG_ENABLED)
39 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_MULTI_LANGUAGE_SUPPORT");
42 const Dali::Toolkit::Text::Character UTF32_A = 0x0041;
52 bool ValidateFontsPerScript::IsValidFont( FontId fontId ) const
54 for( Vector<FontId>::ConstIterator it = mValidFonts.Begin(),
55 endIt = mValidFonts.End();
68 FontId DefaultFonts::FindFont( TextAbstraction::FontClient& fontClient,
69 const TextAbstraction::FontDescription& description,
70 PointSize26Dot6 size ) const
72 for( std::vector<CacheItem>::const_iterator it = mFonts.begin(),
77 const CacheItem& item = *it;
79 if( ( ( TextAbstraction::FontWeight::NONE == description.weight ) || ( description.weight == item.description.weight ) ) &&
80 ( ( TextAbstraction::FontWidth::NONE == description.width ) || ( description.width == item.description.width ) ) &&
81 ( ( TextAbstraction::FontSlant::NONE == description.slant ) || ( description.slant == item.description.slant ) ) &&
82 ( size == fontClient.GetPointSize( item.fontId ) ) &&
83 ( description.family.empty() || ( description.family == item.description.family ) ) )
92 void DefaultFonts::Cache( const TextAbstraction::FontDescription& description, FontId fontId )
95 item.description = description;
97 mFonts.push_back( item );
100 MultilanguageSupport::MultilanguageSupport()
101 : mDefaultFontPerScriptCache(),
102 mValidFontsPerScriptCache(),
103 mSlotDelegate( this )
105 // Initializes the default font cache to zero (invalid font).
106 // Reserves space to cache the default fonts and access them with the script as an index.
107 mDefaultFontPerScriptCache.Resize( TextAbstraction::UNKNOWN + 1, NULL );
109 // Initializes the valid fonts cache to NULL (no valid fonts).
110 // Reserves space to cache the valid fonts and access them with the script as an index.
111 mValidFontsPerScriptCache.Resize( TextAbstraction::UNKNOWN + 1, NULL );
113 // Add custom font directory
114 Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
118 Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager );
119 if( config["customFontDirectory"].Get( path ) )
121 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
122 fontClient.AddCustomFontDirectory( path.c_str() );
126 // Connect LanguageChangedSignal to clear caches when locale is changed.
127 Dali::Adaptor::Get().LanguageChangedSignal().Connect( mSlotDelegate, &Dali::Toolkit::Text::Internal::MultilanguageSupport::OnLanguageChanged );
130 void MultilanguageSupport::OnLanguageChanged( Dali::Adaptor& adaptor )
132 // When locale is changed, font configuration might provide a different font list.
133 // In this case, the original cached font might not be valid for same script.
134 // Therefore, we need to clear caches.
135 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
136 fontClient.ClearCache();
138 mDefaultFontPerScriptCache.Clear();
139 mValidFontsPerScriptCache.Clear();
140 mDefaultFontPerScriptCache.Resize( TextAbstraction::UNKNOWN + 1, NULL );
141 mValidFontsPerScriptCache.Resize( TextAbstraction::UNKNOWN + 1, NULL );
144 MultilanguageSupport::~MultilanguageSupport()
146 // Destroy the default font per script cache.
147 for( Vector<DefaultFonts*>::Iterator it = mDefaultFontPerScriptCache.Begin(),
148 endIt = mDefaultFontPerScriptCache.End();
155 // Destroy the valid fonts per script cache.
156 for( Vector<ValidateFontsPerScript*>::Iterator it = mValidFontsPerScriptCache.Begin(),
157 endIt = mValidFontsPerScriptCache.End();
165 Text::MultilanguageSupport MultilanguageSupport::Get()
167 Text::MultilanguageSupport multilanguageSupportHandle;
169 SingletonService service( SingletonService::Get() );
172 // Check whether the singleton is already created
173 Dali::BaseHandle handle = service.GetSingleton( typeid( Text::MultilanguageSupport ) );
176 // If so, downcast the handle
177 MultilanguageSupport* impl = dynamic_cast< Internal::MultilanguageSupport* >( handle.GetObjectPtr() );
178 multilanguageSupportHandle = Text::MultilanguageSupport( impl );
180 else // create and register the object
182 multilanguageSupportHandle = Text::MultilanguageSupport( new MultilanguageSupport );
183 service.Register( typeid( multilanguageSupportHandle ), multilanguageSupportHandle );
187 return multilanguageSupportHandle;
190 void MultilanguageSupport::SetScripts( const Vector<Character>& text,
191 CharacterIndex startIndex,
192 Length numberOfCharacters,
193 Vector<ScriptRun>& scripts )
195 if( 0u == numberOfCharacters )
197 // Nothing to do if there are no characters.
201 // Find the first index where to insert the script.
202 ScriptRunIndex scriptIndex = 0u;
203 if( 0u != startIndex )
205 for( Vector<ScriptRun>::ConstIterator it = scripts.Begin(),
206 endIt = scripts.End();
208 ++it, ++scriptIndex )
210 const ScriptRun& run = *it;
211 if( startIndex < run.characterRun.characterIndex + run.characterRun.numberOfCharacters )
219 // Stores the current script run.
220 ScriptRun currentScriptRun;
221 currentScriptRun.characterRun.characterIndex = startIndex;
222 currentScriptRun.characterRun.numberOfCharacters = 0u;
223 currentScriptRun.script = TextAbstraction::UNKNOWN;
225 // Reserve some space to reduce the number of reallocations.
226 scripts.Reserve( text.Count() << 2u );
228 // Whether the first valid script needs to be set.
229 bool isFirstScriptToBeSet = true;
231 // Whether the first valid script is a right to left script.
232 bool isParagraphRTL = false;
234 // Count the number of characters which are valid for all scripts. i.e. white spaces or '\n'.
235 Length numberOfAllScriptCharacters = 0u;
237 // Pointers to the text buffer.
238 const Character* const textBuffer = text.Begin();
240 // Traverse all characters and set the scripts.
241 const Length lastCharacter = startIndex + numberOfCharacters;
242 for( Length index = startIndex; index < lastCharacter; ++index )
244 Character character = *( textBuffer + index );
246 // Get the script of the character.
247 Script script = TextAbstraction::GetCharacterScript( character );
249 // Some characters (like white spaces) are valid for many scripts. The rules to set a script
251 // - If they are at the begining of a paragraph they get the script of the first character with
252 // a defined script. If they are at the end, they get the script of the last one.
253 // - If they are between two scripts with the same direction, they get the script of the previous
254 // character with a defined script. If the two scripts have different directions, they get the
255 // script of the first character of the paragraph with a defined script.
257 // Skip those characters valid for many scripts like white spaces or '\n'.
258 bool endOfText = index == lastCharacter;
260 ( TextAbstraction::COMMON == script ) )
262 if( TextAbstraction::EMOJI == currentScriptRun.script )
264 // Emojis doesn't mix well with characters common to all scripts. Insert the emoji run.
265 scripts.Insert( scripts.Begin() + scriptIndex, currentScriptRun );
268 // Initialize the new one.
269 currentScriptRun.characterRun.characterIndex = currentScriptRun.characterRun.characterIndex + currentScriptRun.characterRun.numberOfCharacters;
270 currentScriptRun.characterRun.numberOfCharacters = 0u;
271 currentScriptRun.script = TextAbstraction::UNKNOWN;
272 numberOfAllScriptCharacters = 0u;
275 // Count all these characters to be added into a script.
276 ++numberOfAllScriptCharacters;
278 if( TextAbstraction::IsNewParagraph( character ) )
280 // The character is a new paragraph.
281 // To know when there is a new paragraph is needed because if there is a white space
282 // between two scripts with different directions, it is added to the script with
283 // the same direction than the first script of the paragraph.
284 isFirstScriptToBeSet = true;
286 // Characters common to all scripts at the end of the paragraph are added to the last script.
287 currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
289 // Store the script run.
290 scripts.Insert( scripts.Begin() + scriptIndex, currentScriptRun );
293 // Initialize the new one.
294 currentScriptRun.characterRun.characterIndex = currentScriptRun.characterRun.characterIndex + currentScriptRun.characterRun.numberOfCharacters;
295 currentScriptRun.characterRun.numberOfCharacters = 0u;
296 currentScriptRun.script = TextAbstraction::UNKNOWN;
297 numberOfAllScriptCharacters = 0u;
300 // Get the next character.
302 endOfText = index == lastCharacter;
305 character = *( textBuffer + index );
306 script = TextAbstraction::GetCharacterScript( character );
308 } // end while( !endOfText && ( TextAbstraction::COMMON == script ) )
312 // Last characters of the text are 'white spaces'.
313 // There is nothing else to do. Just add the remaining characters to the last script after this bucle.
317 // Check if it is the first character of a paragraph.
318 if( isFirstScriptToBeSet &&
319 ( TextAbstraction::UNKNOWN != script ) &&
320 ( TextAbstraction::COMMON != script ) &&
321 ( TextAbstraction::EMOJI != script ) )
323 // Sets the direction of the first valid script.
324 isParagraphRTL = TextAbstraction::IsRightToLeftScript( script );
325 isFirstScriptToBeSet = false;
328 if( ( script != currentScriptRun.script ) &&
329 ( TextAbstraction::COMMON != script ) )
331 // Current run needs to be stored and a new one initialized.
333 if( ( isParagraphRTL == TextAbstraction::IsRightToLeftScript( currentScriptRun.script ) ) &&
334 ( TextAbstraction::UNKNOWN != currentScriptRun.script ) )
336 // Previous script has the same direction than the first script of the paragraph.
337 // All the previously skipped characters need to be added to the previous script before it's stored.
338 currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
339 numberOfAllScriptCharacters = 0u;
341 else if( ( TextAbstraction::IsRightToLeftScript( currentScriptRun.script ) == TextAbstraction::IsRightToLeftScript( script ) ) &&
342 ( TextAbstraction::UNKNOWN != currentScriptRun.script ) )
344 // Current script and previous one have the same direction.
345 // All the previously skipped characters need to be added to the previous script before it's stored.
346 currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
347 numberOfAllScriptCharacters = 0u;
349 else if( ( TextAbstraction::UNKNOWN == currentScriptRun.script ) &&
350 ( TextAbstraction::EMOJI == script ) )
352 currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
353 numberOfAllScriptCharacters = 0u;
356 if( 0u != currentScriptRun.characterRun.numberOfCharacters )
358 // Store the script run.
359 scripts.Insert( scripts.Begin() + scriptIndex, currentScriptRun );
363 // Initialize the new one.
364 currentScriptRun.characterRun.characterIndex = currentScriptRun.characterRun.characterIndex + currentScriptRun.characterRun.numberOfCharacters;
365 currentScriptRun.characterRun.numberOfCharacters = numberOfAllScriptCharacters + 1u; // Adds the white spaces which are at the begining of the script.
366 currentScriptRun.script = script;
367 numberOfAllScriptCharacters = 0u;
371 if( TextAbstraction::UNKNOWN != currentScriptRun.script )
373 // Adds white spaces between characters.
374 currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
375 numberOfAllScriptCharacters = 0u;
378 // Add one more character to the run.
379 ++currentScriptRun.characterRun.numberOfCharacters;
383 // Add remaining characters into the last script.
384 currentScriptRun.characterRun.numberOfCharacters += numberOfAllScriptCharacters;
386 if( 0u != currentScriptRun.characterRun.numberOfCharacters )
388 // Store the last run.
389 scripts.Insert( scripts.Begin() + scriptIndex, currentScriptRun );
393 if( scriptIndex < scripts.Count() )
395 // Update the indices of the next script runs.
396 const ScriptRun& run = *( scripts.Begin() + scriptIndex - 1u );
397 CharacterIndex nextCharacterIndex = run.characterRun.characterIndex + run.characterRun.numberOfCharacters;
399 for( Vector<ScriptRun>::Iterator it = scripts.Begin() + scriptIndex,
400 endIt = scripts.End();
404 ScriptRun& run = *it;
405 run.characterRun.characterIndex = nextCharacterIndex;
406 nextCharacterIndex += run.characterRun.numberOfCharacters;
411 void MultilanguageSupport::ValidateFonts( const Vector<Character>& text,
412 const Vector<ScriptRun>& scripts,
413 const Vector<FontDescriptionRun>& fontDescriptions,
414 const TextAbstraction::FontDescription& defaultFontDescription,
415 TextAbstraction::PointSize26Dot6 defaultFontPointSize,
416 CharacterIndex startIndex,
417 Length numberOfCharacters,
418 Vector<FontRun>& fonts )
420 DALI_LOG_INFO( gLogFilter, Debug::General, "-->MultilanguageSupport::ValidateFonts\n" );
422 if( 0u == numberOfCharacters )
424 DALI_LOG_INFO( gLogFilter, Debug::General, "<--MultilanguageSupport::ValidateFonts\n" );
425 // Nothing to do if there are no characters.
429 // Find the first index where to insert the font run.
430 FontRunIndex fontIndex = 0u;
431 if( 0u != startIndex )
433 for( Vector<FontRun>::ConstIterator it = fonts.Begin(),
438 const FontRun& run = *it;
439 if( startIndex < run.characterRun.characterIndex + run.characterRun.numberOfCharacters )
447 // Traverse the characters and validate/set the fonts.
450 DefaultFonts** defaultFontPerScriptCacheBuffer = mDefaultFontPerScriptCache.Begin();
451 ValidateFontsPerScript** validFontsPerScriptCacheBuffer = mValidFontsPerScriptCache.Begin();
453 // Stores the validated font runs.
454 fonts.Reserve( fontDescriptions.Count() );
456 // Initializes a validated font run.
457 FontRun currentFontRun;
458 currentFontRun.characterRun.characterIndex = startIndex;
459 currentFontRun.characterRun.numberOfCharacters = 0u;
460 currentFontRun.fontId = 0u;
462 // Get the font client.
463 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
465 const Character* const textBuffer = text.Begin();
467 // Iterators of the script runs.
468 Vector<ScriptRun>::ConstIterator scriptRunIt = scripts.Begin();
469 Vector<ScriptRun>::ConstIterator scriptRunEndIt = scripts.End();
470 bool isNewParagraphCharacter = false;
472 FontId currentFontId = 0u;
473 FontId previousFontId = 0u;
474 bool isPreviousEmojiScript = false;
476 // Description of fallback font which is selected at current iteration.
477 TextAbstraction::FontDescription selectedFontDescription;
479 CharacterIndex lastCharacter = startIndex + numberOfCharacters;
480 for( Length index = startIndex; index < lastCharacter; ++index )
482 // Get the current character.
483 const Character character = *( textBuffer + index );
484 bool needSoftwareBoldening = false;
485 bool needSoftwareItalic = false;
487 // new description for current character
488 TextAbstraction::FontDescription currentFontDescription;
489 TextAbstraction::PointSize26Dot6 currentFontPointSize = defaultFontPointSize;
490 bool isDefaultFont = true;
491 MergeFontDescriptions( fontDescriptions,
492 defaultFontDescription,
493 defaultFontPointSize,
495 currentFontDescription,
496 currentFontPointSize,
499 // Get the font for the current character.
500 FontId fontId = fontClient.GetFontId( currentFontDescription, currentFontPointSize );
501 currentFontId = fontId;
503 // Get the script for the current character.
504 Script script = GetScript( index,
510 Dali::TextAbstraction::FontDescription description;
511 fontClient.GetDescription( fontId, description );
513 DALI_LOG_INFO( gLogFilter,
515 " Initial font set\n Character : %x, Script : %s, Font : %s \n",
517 Dali::TextAbstraction::ScriptName[script],
518 description.path.c_str() );
522 // Validate whether the current character is supported by the given font.
523 bool isValidFont = false;
525 // Check first in the cache of default fonts per script and size.
527 FontId cachedDefaultFontId = 0u;
528 DefaultFonts* defaultFonts = *( defaultFontPerScriptCacheBuffer + script );
529 if( NULL != defaultFonts )
531 // This cache stores fall-back fonts.
532 cachedDefaultFontId = defaultFonts->FindFont( fontClient,
533 currentFontDescription,
534 currentFontPointSize );
537 // Whether the cached default font is valid.
538 const bool isValidCachedDefaultFont = 0u != cachedDefaultFontId;
540 // The font is valid if it matches with the default one for the current script and size and it's different than zero.
541 isValidFont = isValidCachedDefaultFont && ( fontId == cachedDefaultFontId );
545 // Check if the font supports the character.
546 isValidFont = fontClient.IsCharacterSupportedByFont( fontId, character );
549 bool isCommonScript = false;
550 bool isEmojiScript = TextAbstraction::EMOJI == script;
552 if( isEmojiScript && !isPreviousEmojiScript )
554 if( 0u != currentFontRun.characterRun.numberOfCharacters )
556 // Store the font run.
557 fonts.Insert( fonts.Begin() + fontIndex, currentFontRun );
561 // Initialize the new one.
562 currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters;
563 currentFontRun.characterRun.numberOfCharacters = 0u;
564 currentFontRun.fontId = fontId;
567 // If the given font is not valid, it means either:
568 // - there is no cached font for the current script yet or,
569 // - the user has set a different font than the default one for the current script or,
570 // - the platform default font is different than the default font for the current script.
572 // Need to check if the given font supports the current character.
573 if( !isValidFont ) // (1)
575 // Whether the current character is common for all scripts (i.e. white spaces, ...)
577 // Is not desirable to cache fonts for the common script.
579 // i.e. Consider the text " हिंदी", the 'white space' has assigned the DEVANAGARI script.
580 // The user may have set a font or the platform's default is used.
582 // As the 'white space' is the first character, no font is cached so the font validation
583 // retrieves a glyph from the given font.
585 // Many fonts support 'white spaces' so probably the font set by the user or the platform's default
586 // supports the 'white space'. However, that font may not support the DEVANAGARI script.
587 isCommonScript = TextAbstraction::IsCommonScript( character );
591 if( isValidCachedDefaultFont &&
592 ( isDefaultFont || ( currentFontId == previousFontId ) ) &&
595 // At this point the character common for all scripts has no font assigned.
596 // If there is a valid previously cached default font for it, use that one.
597 fontId = cachedDefaultFontId;
602 // Check in the valid fonts cache.
603 ValidateFontsPerScript* validateFontsPerScript = *( validFontsPerScriptCacheBuffer + script );
605 if( NULL != validateFontsPerScript )
607 // This cache stores valid fonts set by the user.
608 isValidFont = validateFontsPerScript->IsValidFont( fontId );
610 // It may happen that a validated font for a script doesn't have all the glyphs for that script.
611 // i.e a font validated for the CJK script may contain glyphs for the chinese language but not for the Japanese.
614 // Checks if the current character is supported by the font is needed.
615 isValidFont = fontClient.IsCharacterSupportedByFont( fontId, character );
619 if( !isValidFont ) // (2)
621 // The selected font is not stored in any cache.
623 // Checks if the current character is supported by the selected font.
624 isValidFont = fontClient.IsCharacterSupportedByFont( fontId, character );
626 // Emojis are present in many monochrome fonts; prefer color by default.
630 const GlyphIndex glyphIndex = fontClient.GetGlyphIndex( fontId, character );
632 // For color emojis, the font is valid if the glyph is a color glyph (the bitmap is RGBA).
633 isValidFont = fontClient.IsColorGlyph( fontId, glyphIndex );
636 // If there is a valid font, cache it.
639 if( NULL == validateFontsPerScript )
641 validateFontsPerScript = new ValidateFontsPerScript();
643 *( validFontsPerScriptCacheBuffer + script ) = validateFontsPerScript;
646 validateFontsPerScript->mValidFonts.PushBack( fontId );
649 if( !isValidFont && ( fontId != cachedDefaultFontId ) ) // (3)
651 // The selected font by the user or the platform's default font has failed to validate the character.
653 // Checks if the previously discarted cached default font supports the character.
654 bool isValidCachedFont = false;
655 if( isValidCachedDefaultFont )
657 isValidCachedFont = fontClient.IsCharacterSupportedByFont( cachedDefaultFontId, character );
660 if( isValidCachedFont )
662 // Use the cached default font for the script if there is one.
663 fontId = cachedDefaultFontId;
667 // There is no valid cached default font for the script.
669 DefaultFonts* defaultFontsPerScript = NULL;
671 // Emojis are present in many monochrome fonts; prefer color by default.
672 const bool preferColor = ( TextAbstraction::EMOJI == script );
674 // Find a fallback-font.
675 fontId = fontClient.FindFallbackFont( character,
676 currentFontDescription,
677 currentFontPointSize,
682 // If the system does not support a suitable font, fallback to Latin
683 defaultFontsPerScript = *( defaultFontPerScriptCacheBuffer + TextAbstraction::LATIN );
684 if( NULL != defaultFontsPerScript )
686 fontId = defaultFontsPerScript->FindFont( fontClient,
687 currentFontDescription,
688 currentFontPointSize );
694 fontId = fontClient.FindDefaultFont( UTF32_A, currentFontPointSize );
697 if ( script != TextAbstraction::UNKNOWN )
699 // Cache the font if it is not an unknown script
700 if( NULL == defaultFontsPerScript )
702 defaultFontsPerScript = *( defaultFontPerScriptCacheBuffer + script );
704 if( NULL == defaultFontsPerScript )
706 defaultFontsPerScript = new DefaultFonts();
707 *( defaultFontPerScriptCacheBuffer + script ) = defaultFontsPerScript;
710 defaultFontsPerScript->Cache( currentFontDescription, fontId );
713 } // !isValidFont (3)
714 } // !isValidFont (2)
716 } // !isValidFont (1)
720 Dali::TextAbstraction::FontDescription description;
721 fontClient.GetDescription( fontId, description );
722 DALI_LOG_INFO( gLogFilter,
724 " Validated font set\n Character : %x, Script : %s, Font : %s \n",
726 Dali::TextAbstraction::ScriptName[script],
727 description.path.c_str() );
731 if( fontId != currentFontRun.fontId )
733 fontClient.GetDescription(fontId,selectedFontDescription);
736 // Developer sets bold to character but selected font cannot support it
737 needSoftwareBoldening = ( currentFontDescription.weight >= TextAbstraction::FontWeight::BOLD ) && ( selectedFontDescription.weight < TextAbstraction::FontWeight::BOLD );
739 // Developer sets italic to character but selected font cannot support it
740 needSoftwareItalic = ( currentFontDescription.slant == TextAbstraction::FontSlant::ITALIC ) && ( selectedFontDescription.slant < TextAbstraction::FontSlant::ITALIC );
742 // The font is now validated.
743 if( ( fontId != currentFontRun.fontId ) ||
744 isNewParagraphCharacter ||
745 // If font id is same as previous but style is diffrent, initialize new one
746 ( ( fontId == currentFontRun.fontId ) && ( ( needSoftwareBoldening != currentFontRun.softwareBold ) || ( needSoftwareItalic != currentFontRun.softwareItalic ) ) ) )
748 // Current run needs to be stored and a new one initialized.
750 if( 0u != currentFontRun.characterRun.numberOfCharacters )
752 // Store the font run.
753 fonts.Insert( fonts.Begin() + fontIndex, currentFontRun );
757 // Initialize the new one.
758 currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters;
759 currentFontRun.characterRun.numberOfCharacters = 0u;
760 currentFontRun.fontId = fontId;
761 currentFontRun.softwareItalic = needSoftwareItalic;
762 currentFontRun.softwareBold = needSoftwareBoldening;
765 // Add one more character to the run.
766 ++currentFontRun.characterRun.numberOfCharacters;
768 // Whether the current character is a new paragraph character.
769 isNewParagraphCharacter = TextAbstraction::IsNewParagraph( character );
770 previousFontId = currentFontId;
771 isPreviousEmojiScript = isEmojiScript;
772 } // end traverse characters.
774 if( 0u != currentFontRun.characterRun.numberOfCharacters )
776 // Store the last run.
777 fonts.Insert( fonts.Begin() + fontIndex, currentFontRun );
781 if( fontIndex < fonts.Count() )
783 // Update the indices of the next font runs.
784 const FontRun& run = *( fonts.Begin() + fontIndex - 1u );
785 CharacterIndex nextCharacterIndex = run.characterRun.characterIndex + run.characterRun.numberOfCharacters;
787 for( Vector<FontRun>::Iterator it = fonts.Begin() + fontIndex,
794 run.characterRun.characterIndex = nextCharacterIndex;
795 nextCharacterIndex += run.characterRun.numberOfCharacters;
799 DALI_LOG_INFO( gLogFilter, Debug::General, "<--MultilanguageSupport::ValidateFonts\n" );
802 } // namespace Internal
806 } // namespace Toolkit