+ } // !isValidFont (2)
+ } // !isValidFont (1)
+
+ if(isEmojiScript && (previousScript != script))
+ {
+ //New Emoji sequence should select font according to the variation selector (VS15 or VS16).
+ if(0u != currentFontRun.characterRun.numberOfCharacters)
+ {
+ // Store the font run.
+ fonts.Insert(fonts.Begin() + fontIndex, currentFontRun);
+ ++fontIndex;
+ }
+
+ // Initialize the new one.
+ currentFontRun.characterRun.characterIndex = currentFontRun.characterRun.characterIndex + currentFontRun.characterRun.numberOfCharacters;
+ currentFontRun.characterRun.numberOfCharacters = 0u;
+ currentFontRun.fontId = fontId;
+ currentFontRun.isItalicRequired = false;
+ currentFontRun.isBoldRequired = false;
+
+ if(TextAbstraction::IsEmojiColorScript(script) || TextAbstraction::IsEmojiTextScript(script))
+ {
+ bool isModifiedByVariationSelector = false;
+ GlyphIndex glyphIndexChar = fontClient.GetGlyphIndex(fontId, character);
+ GlyphIndex glyphIndexCharByVS = fontClient.GetGlyphIndex(fontId, character, Text::GetVariationSelectorByScript(script));
+
+ isModifiedByVariationSelector = glyphIndexChar != glyphIndexCharByVS;
+
+ if(isModifiedByVariationSelector)
+ {
+ FontId requestedFontId = fontClient.FindDefaultFont(character, currentFontPointSize, IsEmojiColorScript(script));
+ if(0u != requestedFontId)
+ {
+ currentFontRun.fontId = fontId = requestedFontId;
+ isValidFont = true;
+ }
+ }
+ }
+ }
+
+ // Store the font id when the first character is an emoji.
+ if(isEmojiScript)
+ {
+ if(0u != fontId && previousScript != script)
+ {
+ previousEmojiFontId = fontId;
+ }
+ }
+ else
+ {
+ previousEmojiFontId = 0u;
+ }