/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/public-api/math/vector2.h>
#include <memory.h>
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/glyph-metrics-helper.h>
+#include <dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.h>
+
namespace Dali
{
namespace Toolkit
struct View::Impl
{
VisualModelPtr mVisualModel;
+ LogicalModelPtr mLogicalModel;
TextAbstraction::FontClient mFontClient; ///< Handle to the font client.
};
mImpl->mVisualModel = visualModel;
}
+void View::SetLogicalModel(LogicalModelPtr logicalModel)
+{
+ mImpl->mLogicalModel = logicalModel;
+}
+
const Vector2& View::GetControlSize() const
{
if(mImpl->mVisualModel)
GlyphIndex glyphIndex,
Length numberOfGlyphs) const
{
- Length numberOfLaidOutGlyphs = 0u;
- Length numberOfActualLaidOutGlyphs = 0u;
+ Length numberOfLaidOutGlyphs = 0u;
+ Length numberOfActualLaidOutGlyphs = 0u;
+ const float modelCharacterSpacing = mImpl->mVisualModel->GetCharacterSpacing();
+ Vector<CharacterIndex>& glyphToCharacterMap = mImpl->mVisualModel->mGlyphsToCharacters;
+ const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
+ float calculatedAdvance = 0.f;
+ const Character* textBuffer = mImpl->mLogicalModel->mText.Begin();
+
if(mImpl->mVisualModel)
{
+ // Get the character-spacing runs.
+ const Vector<CharacterSpacingGlyphRun>& characterSpacingGlyphRuns = mImpl->mVisualModel->GetCharacterSpacingGlyphRuns();
+
bool textElided = false;
DevelText::EllipsisPosition::Type ellipsisPosition = GetEllipsisPosition();
if(lastGlyphIndexOfLine == index)
{
- penY += -line->descender;
+ penY += -line->descender + line->lineSpacing;
// Get the next line.
++lineIndex;
lastGlyphIndexOfLine = (line->isSplitToTwoHalves ? line->glyphRunSecondHalf.glyphIndex + line->glyphRunSecondHalf.numberOfGlyphs : line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs) - 1u;
- penY += line->ascender + line->lineSpacing;
+ penY += line->ascender;
}
}
}
const LineRun& elidedLine = *ellipsisLine;
if((1u == numberOfLines) &&
- (GetLineHeight(elidedLine) > mImpl->mVisualModel->mControlSize.height))
+ (GetLineHeight(elidedLine, true) > mImpl->mVisualModel->mControlSize.height))
{
// Replace the first glyph with ellipsis glyph
auto indexOfFirstGlyph = (ellipsisPosition == DevelText::EllipsisPosition::START) ? startIndexOfEllipsis : 0u;
firstPenSet = true;
}
- removedGlypsWidth += std::min(glyphToRemove.advance, (glyphToRemove.xBearing + glyphToRemove.width));
+ const float characterSpacing = GetGlyphCharacterSpacing(indexOfEllipsis, characterSpacingGlyphRuns, modelCharacterSpacing);
+ calculatedAdvance = GetCalculatedAdvance(*(textBuffer + (*(glyphToCharacterMapBuffer + indexOfEllipsis))), characterSpacing, glyphToRemove.advance);
+ removedGlypsWidth += std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width));
// Calculate the width of the ellipsis glyph and check if it fits.
const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing;
return 0.0f;
}
+Text::Underline::Type View::GetUnderlineType() const
+{
+ Text::Underline::Type type = Text::Underline::Type::SOLID;
+ if(mImpl->mVisualModel)
+ {
+ type = mImpl->mVisualModel->GetUnderlineType();
+ }
+ return type;
+}
+
+float View::GetDashedUnderlineWidth() const
+{
+ float width = 0.0f;
+ if(mImpl->mVisualModel)
+ {
+ width = mImpl->mVisualModel->GetDashedUnderlineWidth();
+ }
+ return width;
+}
+
+float View::GetDashedUnderlineGap() const
+{
+ float gap = 0.0f;
+ if(mImpl->mVisualModel)
+ {
+ gap = mImpl->mVisualModel->GetDashedUnderlineGap();
+ }
+ return gap;
+}
+
Length View::GetNumberOfUnderlineRuns() const
{
if(mImpl->mVisualModel)
return 0u;
}
-void View::GetUnderlineRuns(GlyphRun* underlineRuns,
- UnderlineRunIndex index,
- Length numberOfRuns) const
+void View::GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns,
+ UnderlineRunIndex index,
+ Length numberOfRuns) const
{
if(mImpl->mVisualModel)
{
return secondMiddleIndexOfElidedGlyphs;
}
+const Vector4& View::GetStrikethroughColor() const
+{
+ return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetStrikethroughColor() : Vector4::ZERO;
+}
+
+bool View::IsStrikethroughEnabled() const
+{
+ return (mImpl->mVisualModel) ? mImpl->mVisualModel->IsStrikethroughEnabled() : false;
+}
+
+float View::GetStrikethroughHeight() const
+{
+ return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetStrikethroughHeight() : 0.0f;
+}
+
+Length View::GetNumberOfStrikethroughRuns() const
+{
+ if(mImpl->mVisualModel)
+ {
+ return mImpl->mVisualModel->GetNumberOfStrikethroughRuns();
+ }
+
+ return 0u;
+}
+
+void View::GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns,
+ StrikethroughRunIndex index,
+ Length numberOfRuns) const
+{
+ if(mImpl->mVisualModel)
+ {
+ mImpl->mVisualModel->GetStrikethroughRuns(strikethroughRuns,
+ index,
+ numberOfRuns);
+ }
+}
+
+Length View::GetNumberOfBoundedParagraphRuns() const
+{
+ if(mImpl->mLogicalModel)
+ {
+ return mImpl->mLogicalModel->GetNumberOfBoundedParagraphRuns();
+ }
+
+ return 0u;
+}
+
+const Vector<BoundedParagraphRun>& View::GetBoundedParagraphRuns() const
+{
+ return mImpl->mLogicalModel->GetBoundedParagraphRuns();
+}
+
+Length View::GetNumberOfCharacterSpacingGlyphRuns() const
+{
+ return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetNumberOfCharacterSpacingGlyphRuns() : 0u;
+}
+
+const Vector<CharacterSpacingGlyphRun>& View::GetCharacterSpacingGlyphRuns() const
+{
+ return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetCharacterSpacingGlyphRuns() : GetEmptyCharacterSpacingGlyphRuns();
+}
+
+const float View::GetCharacterSpacing() const
+{
+ return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetCharacterSpacing() : 0.f;
+}
+
+const Character* View::GetTextBuffer() const
+{
+ return (mImpl->mVisualModel) ? mImpl->mLogicalModel->mText.Begin() : nullptr;
+}
+
+const Vector<CharacterIndex>& View::GetGlyphsToCharacters() const
+{
+ return mImpl->mVisualModel->GetGlyphsToCharacters();
+}
+
} // namespace Text
} // namespace Toolkit