+ glyphMetrics.width += (firstGlyph.isItalicRequired && !isItalicFont) ? TextAbstraction::FontClient::DEFAULT_ITALIC_ANGLE * firstGlyph.height : 0.f;
+}
+
+void GetGlyphMetricsFromCharacterIndex(CharacterIndex index,
+ const VisualModelPtr& visualModel,
+ const LogicalModelPtr& logicalModel,
+ MetricsPtr& metrics,
+ GlyphMetrics& glyphMetrics,
+ GlyphIndex& glyphIndex,
+ Length& numberOfGlyphs)
+{
+ const GlyphIndex* const charactersToGlyphBuffer = visualModel->mCharactersToGlyph.Begin();
+ const Length* const glyphsPerCharacterBuffer = visualModel->mGlyphsPerCharacter.Begin();
+ const GlyphInfo* const glyphInfoBuffer = visualModel->mGlyphs.Begin();
+ Vector<CharacterIndex>& glyphToCharacterMap = visualModel->mGlyphsToCharacters;
+ const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
+ const float modelCharacterSpacing = visualModel->GetCharacterSpacing();
+
+ // Get the character-spacing runs.
+ const Vector<CharacterSpacingGlyphRun>& characterSpacingGlyphRuns = visualModel->GetCharacterSpacingGlyphRuns();
+
+ //Takes the character index, obtains the glyph index (and the number of Glyphs) from it and finally gets the glyph metrics.
+ glyphIndex = *(charactersToGlyphBuffer + index);
+ numberOfGlyphs = *(glyphsPerCharacterBuffer + index);
+
+ float calculatedAdvance = 0.f;
+
+ const float characterSpacing = GetGlyphCharacterSpacing(glyphIndex, characterSpacingGlyphRuns, modelCharacterSpacing);
+ calculatedAdvance = GetCalculatedAdvance(*(logicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + glyphIndex))), characterSpacing, (*(visualModel->mGlyphs.Begin() + glyphIndex)).advance);
+
+ // Get the metrics for the group of glyphs.
+ GetGlyphsMetrics(glyphIndex,
+ numberOfGlyphs,
+ glyphMetrics,
+ glyphInfoBuffer,
+ metrics,
+ calculatedAdvance);
+}
+
+float GetCalculatedAdvance(unsigned int character, float characterSpacing, float advance)
+{
+ //Gets the final advance value by adding the CharacterSpacing value to it
+ //In some cases the CharacterSpacing should not be added. Ex: when the glyph is a ZWSP (Zero Width Space)
+ return (TextAbstraction::IsZeroWidthNonJoiner(character) || TextAbstraction::IsZeroWidthJoiner(character) ||
+ TextAbstraction::IsZeroWidthSpace(character) || TextAbstraction::IsNewParagraph(character) ||
+ TextAbstraction::IsLeftToRightMark(character) || TextAbstraction::IsRightToLeftMark(character))
+ ? advance
+ : advance + characterSpacing;