2 #include <dali-toolkit/internal/text/characters-helper-functions.h>
5 #include <dali-toolkit/internal/text/emoji-helper.h>
13 CharacterRun RetrieveClusteredCharactersOfCharacterIndex(const VisualModelPtr& visualModel,
14 const LogicalModelPtr& logicalModel,
15 const CharacterIndex& characterIndex)
18 CharacterRun clusteredCharacters;
19 clusteredCharacters.characterIndex = characterIndex;
20 clusteredCharacters.numberOfCharacters = 1u;
22 const GlyphIndex* const charactersToGlyphBuffer = visualModel->mCharactersToGlyph.Begin();
23 const Length* const charactersPerGlyphBuffer = visualModel->mCharactersPerGlyph.Begin();
24 const CharacterIndex* const glyphsToCharacters = visualModel->mGlyphsToCharacters.Begin();
26 GlyphIndex glyphIndex = *(charactersToGlyphBuffer + characterIndex);
27 Length actualNumberOfCharacters = *(charactersPerGlyphBuffer + glyphIndex);
29 if(actualNumberOfCharacters > 1u)
31 const Script script = logicalModel->GetScript(characterIndex);
32 // Prevents to break the Latin ligatures like fi, ff, or Arabic ﻻ, ...
33 // Keep actual index of character as is. Because these characters cannot be clustered.
35 if(!HasLigatureMustBreak(script))
37 clusteredCharacters.numberOfCharacters = actualNumberOfCharacters;
38 clusteredCharacters.characterIndex = *(glyphsToCharacters + glyphIndex); // firstCharacterIndex
43 while(0u == actualNumberOfCharacters)
46 actualNumberOfCharacters = *(charactersPerGlyphBuffer + glyphIndex);
49 clusteredCharacters.characterIndex = *(glyphsToCharacters + glyphIndex); // firstCharacterIndex
50 clusteredCharacters.numberOfCharacters = actualNumberOfCharacters;
53 return clusteredCharacters;
58 } // namespace Toolkit