/*
- * 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 <memory.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/internal/text/glyph-metrics-helper.h>
#include <dali-toolkit/internal/text/line-run.h>
namespace Dali
return mModel->GetUnderlineHeight();
}
+Text::Underline::Type ViewModel::GetUnderlineType() const
+{
+ return mModel->GetUnderlineType();
+}
+
+float ViewModel::GetDashedUnderlineWidth() const
+{
+ return mModel->GetDashedUnderlineWidth();
+}
+
+float ViewModel::GetDashedUnderlineGap() const
+{
+ return mModel->GetDashedUnderlineGap();
+}
+
Length ViewModel::GetNumberOfUnderlineRuns() const
{
return mModel->GetNumberOfUnderlineRuns();
}
-void ViewModel::GetUnderlineRuns(GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const
+void ViewModel::GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const
{
mModel->GetUnderlineRuns(underlineRuns, index, numberOfRuns);
}
return mModel->GetHyphensCount();
}
+const float ViewModel::GetCharacterSpacing() const
+{
+ return mModel->GetCharacterSpacing();
+}
+
+const Character* ViewModel::GetTextBuffer() const
+{
+ return mModel->GetTextBuffer();
+}
+
+const Vector<CharacterIndex>& ViewModel::GetGlyphsToCharacters() const
+{
+ return mModel->GetGlyphsToCharacters();
+}
+
void ViewModel::ElideGlyphs()
{
mIsTextElided = false;
mStartIndexOfElidedGlyphs = mFirstMiddleIndexOfElidedGlyphs = mSecondMiddleIndexOfElidedGlyphs = 0;
mEndIndexOfElidedGlyphs = mModel->GetNumberOfGlyphs() - 1u;
- auto ellipsisPosition = GetEllipsisPosition();
+ auto ellipsisPosition = GetEllipsisPosition();
+ auto characterSpacing = GetCharacterSpacing();
+ const Character* textBuffer = GetTextBuffer();
+ const Vector<CharacterIndex>& glyphToCharacterMap = GetGlyphsToCharacters();
+ const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
+ float calculatedAdvance = 0.f;
if(IsTextElideEnabled())
{
// Need to reshape the glyph as the font may be different in size.
const GlyphInfo& ellipsisGlyph = fontClient.GetEllipsisGlyph(fontClient.GetPointSize(glyphToRemove.fontId));
- if(!firstPenSet)
+ if(!firstPenSet || EqualsZero(glyphToRemove.advance))
{
const Vector2& position = *(elidedPositionsBuffer + indexOfEllipsis);
firstPenSet = true;
}
- removedGlypsWidth += std::min(glyphToRemove.advance, (glyphToRemove.xBearing + glyphToRemove.width));
+ 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;
}
}
+float ViewModel::GetStrikethroughHeight() const
+{
+ return mModel->GetStrikethroughHeight();
+}
+
+const Vector4& ViewModel::GetStrikethroughColor() const
+{
+ return mModel->GetStrikethroughColor();
+}
+
+bool ViewModel::IsStrikethroughEnabled() const
+{
+ return mModel->IsStrikethroughEnabled();
+}
+
+Length ViewModel::GetNumberOfStrikethroughRuns() const
+{
+ return mModel->GetNumberOfStrikethroughRuns();
+}
+
+void ViewModel::GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const
+{
+ mModel->GetStrikethroughRuns(strikethroughRuns, index, numberOfRuns);
+}
+
+Length ViewModel::GetNumberOfBoundedParagraphRuns() const
+{
+ return mModel->GetNumberOfBoundedParagraphRuns();
+}
+
+const Vector<BoundedParagraphRun>& ViewModel::GetBoundedParagraphRuns() const
+{
+ return mModel->GetBoundedParagraphRuns();
+}
+
+Length ViewModel::GetNumberOfCharacterSpacingGlyphRuns() const
+{
+ return mModel->GetNumberOfCharacterSpacingGlyphRuns();
+}
+
+const Vector<CharacterSpacingGlyphRun>& ViewModel::GetCharacterSpacingGlyphRuns() const
+{
+ return mModel->GetCharacterSpacingGlyphRuns();
+}
+
} // namespace Text
} // namespace Toolkit