// INTERNAL INCLUDES
#include <dali-toolkit/internal/text/cursor-helper-functions.h>
#include <dali-toolkit/internal/text/glyph-metrics-helper.h>
-#include <dali-toolkit/internal/text/text-controller-impl-event-handler.h>
+#include <dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.h>
+#include <dali-toolkit/internal/text/controller/text-controller-impl-event-handler.h>
using namespace Dali;
const GlyphIndex glyphStart = *(charactersToGlyphBuffer + selectionStart);
const Length numberOfGlyphs = *(glyphsPerCharacterBuffer + selectionEndMinusOne);
const GlyphIndex glyphEnd = *(charactersToGlyphBuffer + selectionEndMinusOne) + ((numberOfGlyphs > 0) ? numberOfGlyphs - 1u : 0u);
- const float characterSpacing = visualModel->GetCharacterSpacing();
+ const float modelCharacterSpacing = visualModel->GetCharacterSpacing();
Vector<CharacterIndex>& glyphToCharacterMap = visualModel->mGlyphsToCharacters;
const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
+ // Get the character-spacing runs.
+ const Vector<CharacterSpacingGlyphRun>& characterSpacingGlyphRuns = visualModel->GetCharacterSpacingGlyphRuns();
+
// Get the lines where the glyphs are laid-out.
const LineRun* lineRun = visualModel->mLines.Begin();
lineRun += firstLineIndex;
- selectionBoxInfo->lineHeight = GetLineHeight(*lineRun);
+ // The line height is the addition of the line ascender and the line descender.
+ // However, the line descender has a negative value, hence the subtraction also line spacing should not be included in selection height.
+ selectionBoxInfo->lineHeight = lineRun->ascender - lineRun->descender;
GlyphIndex lastGlyphOfLine = lineRun->glyphRun.glyphIndex + lineRun->glyphRun.numberOfGlyphs - 1u;
// Traverse the glyphs.
for(GlyphIndex index = glyphStart; index <= glyphEnd; ++index)
{
- const GlyphInfo& glyph = *(glyphsBuffer + index);
- const Vector2& position = *(positionsBuffer + index);
- calculatedAdvance = GetCalculatedAdvance(*(logicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + index))), characterSpacing, glyph.advance);
+ const float characterSpacing = GetGlyphCharacterSpacing(index, characterSpacingGlyphRuns, modelCharacterSpacing);
+ const GlyphInfo& glyph = *(glyphsBuffer + index);
+ const Vector2& position = *(positionsBuffer + index);
+ calculatedAdvance = GetCalculatedAdvance(*(logicalModel->mText.Begin() + (*(glyphToCharacterMapBuffer + index))), characterSpacing, glyph.advance);
if(splitStartGlyph)
{
++lineIndex;
if(lineIndex < firstLineIndex + numberOfLines)
{
+ float currentLineSpacing = lineRun->lineSpacing;
+
// Retrieve the next line.
++lineRun;
selectionBoxInfo->maxX = MIN_FLOAT;
// Update the line's vertical offset.
- selectionBoxInfo->lineOffset = currentLineOffset + currentLineHeight;
+ selectionBoxInfo->lineOffset = currentLineOffset + currentLineHeight + currentLineSpacing;
+
+ // The line height is the addition of the line ascender and the line descender.
+ // However, the line descender has a negative value, hence the subtraction also line spacing should not be included in selection height.
+ selectionBoxInfo->lineHeight = lineRun->ascender - lineRun->descender;
- selectionBoxInfo->lineHeight = GetLineHeight(*lineRun);
+ if(lineRun->lineSpacing > 0)
+ {
+ selectionBoxInfo->lineHeight += lineRun->lineSpacing;
+ }
}
}
}