2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/text-view.h>
22 #include <dali/devel-api/text-abstraction/font-client.h>
23 #include <dali/public-api/math/vector2.h>
27 #include <dali-toolkit/internal/text/glyph-metrics-helper.h>
28 #include <dali-toolkit/internal/text/rendering/styles/character-spacing-helper-functions.h>
30 namespace Dali::Toolkit::Text
36 /// If ellipsis is enabled, calculate the number of laid out glyphs.
37 /// Otherwise use the given number of glyphs.
38 void CalculateNumberOfLaidOutGlyphes(
39 const bool hasEllipsis,
41 Length& numberOfLaidOutGlyphs,
42 Length& numberOfActualLaidOutGlyphs,
43 const Length& numberOfGlyphs,
44 const DevelText::EllipsisPosition::Type& ellipsisPosition,
45 const LineRun*& ellipsisLine,
46 const Length& numberOfLines,
47 const LineRun* const& lines)
52 numberOfLaidOutGlyphs = numberOfGlyphs;
54 switch(ellipsisPosition)
56 case DevelText::EllipsisPosition::START:
58 numberOfActualLaidOutGlyphs = numberOfGlyphs - ellipsisLine->glyphRun.glyphIndex;
61 case DevelText::EllipsisPosition::MIDDLE:
63 numberOfActualLaidOutGlyphs = 0u;
64 for(Length lineIndex = 0u ; lineIndex < numberOfLines ; lineIndex++)
66 numberOfActualLaidOutGlyphs += lines[lineIndex].glyphRun.numberOfGlyphs + lines[lineIndex].glyphRunSecondHalf.numberOfGlyphs;
70 case DevelText::EllipsisPosition::END:
72 numberOfActualLaidOutGlyphs = ellipsisLine->glyphRun.glyphIndex + ellipsisLine->glyphRun.numberOfGlyphs;
79 numberOfActualLaidOutGlyphs = numberOfLaidOutGlyphs = numberOfGlyphs;
83 void InsertEllipsisGlyph(
85 GlyphIndex& indexOfEllipsis,
86 Length& numberOfRemovedGlyphs,
87 Vector2*& glyphPositions,
88 TextAbstraction::FontClient& fontClient,
89 const Vector<CharacterSpacingGlyphRun>& characterSpacingGlyphRuns,
90 const float& modelCharacterSpacing,
91 float& calculatedAdvance,
92 const Character*& textBuffer,
93 const CharacterIndex*& glyphToCharacterMapBuffer,
94 const Length& numberOfGlyphs,
95 const bool isTailMode,
96 const LineRun*& ellipsisLine,
97 const Length& numberOfLaidOutGlyphs)
99 // firstPenX, penY and firstPenSet are used to position the ellipsis glyph if needed.
100 float firstPenX = 0.f; // Used if rtl text is elided.
102 bool firstPenSet = false;
103 bool inserted = false;
105 float removedGlyphsWidth = 0.f;
109 const GlyphInfo& glyphToRemove = *(glyphs + indexOfEllipsis);
111 if(0u != glyphToRemove.fontId)
113 // i.e. The font id of the glyph shaped from the '\n' character is zero.
115 // Need to reshape the glyph as the font may be different in size.
116 const GlyphInfo& ellipsisGlyph = fontClient.GetEllipsisGlyph(fontClient.GetPointSize(glyphToRemove.fontId));
120 const Vector2& position = *(glyphPositions + indexOfEllipsis);
122 // Calculates the penY of the current line. It will be used to position the ellipsis glyph.
123 penY = position.y + glyphToRemove.yBearing;
125 // Calculates the first penX which will be used if rtl text is elided.
126 firstPenX = position.x - glyphToRemove.xBearing;
127 if(firstPenX < -ellipsisGlyph.xBearing)
129 // Avoids to exceed the bounding box when rtl text is elided.
130 firstPenX = -ellipsisGlyph.xBearing;
133 removedGlyphsWidth = -ellipsisGlyph.xBearing;
138 const float characterSpacing = GetGlyphCharacterSpacing(indexOfEllipsis, characterSpacingGlyphRuns, modelCharacterSpacing);
139 calculatedAdvance = GetCalculatedAdvance(*(textBuffer + (*(glyphToCharacterMapBuffer + indexOfEllipsis))), characterSpacing, glyphToRemove.advance);
140 removedGlyphsWidth += std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width));
142 // Calculate the width of the ellipsis glyph and check if it fits.
143 const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing;
144 if((ellipsisGlyphWidth < removedGlyphsWidth) || (isTailMode ? (indexOfEllipsis == 0u) : (indexOfEllipsis == numberOfGlyphs - 1u)))
146 GlyphInfo& glyphInfo = *(glyphs + indexOfEllipsis);
147 Vector2& position = *(glyphPositions + indexOfEllipsis);
148 position.x -= (0.f > glyphInfo.xBearing) ? glyphInfo.xBearing : 0.f;
150 // Replace the glyph by the ellipsis glyph.
151 glyphInfo = ellipsisGlyph;
153 // Change the 'x' and 'y' position of the ellipsis glyph.
154 if(position.x > firstPenX)
158 // To handle case of the mixed languages (LTR then RTL) with
159 // EllipsisPosition::END and the LayoutDirection::RIGHT_TO_LEFT
160 float nextXPositions = ellipsisLine->width;
161 if(indexOfEllipsis + 1u < numberOfGlyphs)
163 Vector2& positionOfNextGlyph = *(glyphPositions + indexOfEllipsis + 1u);
164 nextXPositions = positionOfNextGlyph.x;
167 if(position.x > nextXPositions) // RTL language
169 if((indexOfEllipsis > 0u) && ((position.x - nextXPositions) > removedGlyphsWidth))
171 // To handle mixed directions
172 // Re-calculates the first penX which will be used if rtl text is elided.
173 firstPenX = position.x - glyphToRemove.xBearing;
174 if(firstPenX < -ellipsisGlyph.xBearing)
176 // Avoids to exceed the bounding box when rtl text is elided.
177 firstPenX = -ellipsisGlyph.xBearing;
179 //Reset the width of removed glyphs
180 removedGlyphsWidth = std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width)) - ellipsisGlyph.xBearing;
187 // To handle the case of RTL language with EllipsisPosition::END
188 position.x = firstPenX + removedGlyphsWidth - ellipsisGlyphWidth;
194 // To handle the case of LTR language with EllipsisPosition::START
195 position.x = firstPenX + removedGlyphsWidth - ellipsisGlyphWidth;
202 // To handle case of the mixed languages (RTL then LTR) with
203 // EllipsisPosition::START and the LayoutDirection::RIGHT_TO_LEFT
204 float nextXPositions = ellipsisLine->width;
205 if(indexOfEllipsis + 1u < numberOfGlyphs)
207 Vector2& positionOfNextGlyph = *(glyphPositions + indexOfEllipsis + 1u);
208 nextXPositions = positionOfNextGlyph.x;
211 if(position.x < nextXPositions) // LTR language
213 position.x = firstPenX + removedGlyphsWidth - ellipsisGlyphWidth;
215 if((position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) > nextXPositions)
217 position.x -= (position.x + ellipsisGlyphWidth + ellipsisGlyph.xBearing) - nextXPositions;
223 position.x += ellipsisGlyph.xBearing;
224 position.y = penY - ellipsisGlyph.yBearing;
232 if(isTailMode && indexOfEllipsis > 0u)
234 // Tail Mode: remove glyphs from startIndexOfEllipsis then decrement indexOfEllipsis, until arrive to index zero.
237 else if(!isTailMode && indexOfEllipsis < numberOfLaidOutGlyphs - 1u)
239 // Not Tail Mode: remove glyphs from startIndexOfEllipsis then increase indexOfEllipsis, until arrive to last index (numberOfGlyphs - 1u).
244 // No space for the ellipsis.
247 ++numberOfRemovedGlyphs;
252 /// 'Removes' all the glyphs after the ellipsis glyph.
253 void RemoveAllGlyphsAfterEllipsisGlyph(
254 const DevelText::EllipsisPosition::Type& ellipsisPosition,
255 Length& numberOfLaidOutGlyphs,
256 const Length& numberOfActualLaidOutGlyphs,
257 const Length& numberOfRemovedGlyphs,
258 const bool isTailMode,
259 const GlyphIndex& indexOfEllipsis,
260 const LineRun*& ellipsisNextLine,
261 const LineRun*& ellipsisLine,
263 Vector2*& glyphPositions,
264 const Length& numberOfGlyphs,
265 const GlyphIndex& startIndexOfEllipsis,
266 VisualModelPtr& visualModel)
268 switch(ellipsisPosition)
270 case DevelText::EllipsisPosition::MIDDLE:
272 //Reduce size, shift glyphs and start from ellipsis glyph
273 numberOfLaidOutGlyphs = numberOfActualLaidOutGlyphs - numberOfRemovedGlyphs;
275 GlyphIndex firstMiddleIndexOfElidedGlyphs = 0u;
276 GlyphIndex secondMiddleIndexOfElidedGlyphs = 0u;
278 bool isOnlySecondHalf = false;
281 // Multi-lines case with MIDDLE
282 // In case the Ellipsis in the end of line,
283 // then this index will be the firstMiddleIndex.
284 // The secondMiddleIndex will be the fisrt index in next line.
285 // But in case there is no line after Ellipsis's line then secondMiddleIndex and endIndex equal firstMiddle
287 // A: are laid out glyphs in line has Ellipsis in the end.
288 // N: are laid out glyphs in lines after removed lines.
289 // R: are removed glyphs.
290 // L: are removed glyphs when removed lines.
291 // AAAAAAAAAAAA...RRR => Here's the firstMiddleIndex (First index after last A)
294 // NNNNNNNNNNNNNN => Here's the secondMiddleIndex (First N)
297 firstMiddleIndexOfElidedGlyphs = indexOfEllipsis;
298 if(ellipsisNextLine != nullptr)
300 secondMiddleIndexOfElidedGlyphs = ellipsisNextLine->glyphRun.glyphIndex;
303 secondMiddleIndexOfElidedGlyphs = firstMiddleIndexOfElidedGlyphs;
304 visualModel->SetEndIndexOfElidedGlyphs(firstMiddleIndexOfElidedGlyphs);
308 // Single line case with MIDDLE
309 // In case the Ellipsis in the middle of line,
310 // Then the last index in first half will be firstMiddleIndex.
311 // And the indexOfEllipsis will be secondMiddleIndex, which is the first index in second half.
313 // A: are laid out glyphs in first half of line.
314 // N: are laid out glyphs in second half of line.
315 // R: are removed glyphs.
316 // L: re removed glyphs when layouting text
317 // AAAAAAALLLLLLLLLLLRRR...NNNNN
318 // firstMiddleIndex (index of last A)
319 // secondMiddleIndex (index before first N)
321 firstMiddleIndexOfElidedGlyphs = (ellipsisLine->glyphRun.numberOfGlyphs > 0u) ? (ellipsisLine->glyphRun.glyphIndex + ellipsisLine->glyphRun.numberOfGlyphs - 1u) : (ellipsisLine->glyphRun.glyphIndex);
322 secondMiddleIndexOfElidedGlyphs = indexOfEllipsis;
323 isOnlySecondHalf = ellipsisLine->glyphRun.numberOfGlyphs == 0u && ellipsisLine->glyphRunSecondHalf.numberOfGlyphs > 0u;
326 visualModel->SetFirstMiddleIndexOfElidedGlyphs(firstMiddleIndexOfElidedGlyphs);
327 visualModel->SetSecondMiddleIndexOfElidedGlyphs(secondMiddleIndexOfElidedGlyphs);
329 // The number of shifted glyphs and shifting positions will be different according to Single-line or Multi-lines.
330 // isOnlySecondHalf will be true when MIDDLE Ellipsis glyph in single line.
333 Length numberOfSecondHalfGlyphs = numberOfLaidOutGlyphs - firstMiddleIndexOfElidedGlyphs;
335 //Copy elided glyphs after the ellipsis glyph.
336 memcpy(glyphs + firstMiddleIndexOfElidedGlyphs, glyphs + secondMiddleIndexOfElidedGlyphs, numberOfSecondHalfGlyphs * sizeof(GlyphInfo));
337 memcpy(glyphPositions + firstMiddleIndexOfElidedGlyphs, glyphPositions + secondMiddleIndexOfElidedGlyphs, numberOfSecondHalfGlyphs * sizeof(Vector2));
340 Length numberOfSecondHalfGlyphs = numberOfLaidOutGlyphs - firstMiddleIndexOfElidedGlyphs + 1u;
342 // Make sure that out-of-boundary does not occur.
343 if(secondMiddleIndexOfElidedGlyphs + numberOfSecondHalfGlyphs > numberOfGlyphs)
345 numberOfSecondHalfGlyphs = numberOfGlyphs - secondMiddleIndexOfElidedGlyphs;
348 //Copy elided glyphs after the ellipsis glyph.
349 memcpy(glyphs + firstMiddleIndexOfElidedGlyphs + 1u, glyphs + secondMiddleIndexOfElidedGlyphs, numberOfSecondHalfGlyphs * sizeof(GlyphInfo));
350 memcpy(glyphPositions + firstMiddleIndexOfElidedGlyphs + 1u, glyphPositions + secondMiddleIndexOfElidedGlyphs, numberOfSecondHalfGlyphs * sizeof(Vector2));
355 case DevelText::EllipsisPosition::START:
357 numberOfLaidOutGlyphs = numberOfActualLaidOutGlyphs - numberOfRemovedGlyphs;
358 //Copy elided glyphs after the ellipsis glyph.
359 memcpy(glyphs, glyphs + startIndexOfEllipsis + numberOfRemovedGlyphs, numberOfLaidOutGlyphs * sizeof(GlyphInfo));
360 memcpy(glyphPositions, glyphPositions + startIndexOfEllipsis + numberOfRemovedGlyphs, numberOfLaidOutGlyphs * sizeof(Vector2));
361 visualModel->SetStartIndexOfElidedGlyphs(indexOfEllipsis);
365 case DevelText::EllipsisPosition::END:
367 numberOfLaidOutGlyphs = numberOfActualLaidOutGlyphs - numberOfRemovedGlyphs;
368 visualModel->SetEndIndexOfElidedGlyphs(indexOfEllipsis);
372 } // unnamed namespace
377 VisualModelPtr mVisualModel;
378 LogicalModelPtr mLogicalModel;
379 TextAbstraction::FontClient mFontClient; ///< Handle to the font client.
385 mImpl = new View::Impl();
387 mImpl->mFontClient = TextAbstraction::FontClient::Get();
395 void View::SetVisualModel(VisualModelPtr visualModel)
397 mImpl->mVisualModel = visualModel;
400 void View::SetLogicalModel(LogicalModelPtr logicalModel)
402 mImpl->mLogicalModel = logicalModel;
405 const Vector2& View::GetControlSize() const
407 if(mImpl->mVisualModel)
409 return mImpl->mVisualModel->mControlSize;
412 return Vector2::ZERO;
415 const Vector2& View::GetLayoutSize() const
417 if(mImpl->mVisualModel)
419 return mImpl->mVisualModel->GetLayoutSize();
422 return Vector2::ZERO;
425 Length View::GetNumberOfGlyphs() const
427 if(mImpl->mVisualModel)
429 const VisualModel& model = *mImpl->mVisualModel;
431 const Length glyphCount = model.mGlyphs.Count();
432 const Length positionCount = model.mGlyphPositions.Count();
434 DALI_ASSERT_DEBUG(positionCount <= glyphCount && "Invalid glyph positions in Model");
436 return (positionCount < glyphCount) ? positionCount : glyphCount;
442 Length View::GetGlyphs(GlyphInfo* glyphs,
443 Vector2* glyphPositions,
444 float& minLineOffset,
445 GlyphIndex glyphIndex,
446 Length numberOfGlyphs) const
448 Length numberOfLaidOutGlyphs = 0u;
449 Length numberOfActualLaidOutGlyphs = 0u;
450 const float modelCharacterSpacing = mImpl->mVisualModel->GetCharacterSpacing();
451 Vector<CharacterIndex>& glyphToCharacterMap = mImpl->mVisualModel->mGlyphsToCharacters;
452 const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
453 float calculatedAdvance = 0.f;
454 const Character* textBuffer = mImpl->mLogicalModel->mText.Begin();
456 if(mImpl->mVisualModel)
458 // Get the character-spacing runs.
459 const Vector<CharacterSpacingGlyphRun>& characterSpacingGlyphRuns = mImpl->mVisualModel->GetCharacterSpacingGlyphRuns();
461 bool textElided = false;
462 DevelText::EllipsisPosition::Type ellipsisPosition = GetEllipsisPosition();
464 //Reset indices of ElidedGlyphs
465 mImpl->mVisualModel->SetStartIndexOfElidedGlyphs(0u);
466 mImpl->mVisualModel->SetEndIndexOfElidedGlyphs(numberOfGlyphs - 1u); // Initialization is the last index of Glyphs
467 mImpl->mVisualModel->SetFirstMiddleIndexOfElidedGlyphs(0u);
468 mImpl->mVisualModel->SetSecondMiddleIndexOfElidedGlyphs(0u);
470 // If ellipsis is enabled, the number of glyphs the layout engine has laid out may be less than 'numberOfGlyphs'.
471 // Check the last laid out line to know if the layout engine elided some text.
473 const Length numberOfLines = mImpl->mVisualModel->mLines.Count();
474 if(numberOfLines > 0u)
476 const LineRun* const lines = mImpl->mVisualModel->mLines.Begin();
478 //Get line of ellipsis
479 const LineRun* ellipsisLine = nullptr;
480 const LineRun* ellipsisNextLine = nullptr;
481 bool hasEllipsis = false;
482 for(Length lineIndex = 0; lineIndex < numberOfLines; lineIndex++)
484 const LineRun* line = (lines + lineIndex);
489 if(lineIndex < numberOfLines - 1u)
491 ellipsisNextLine = (lines + lineIndex + 1u);
497 CalculateNumberOfLaidOutGlyphes(hasEllipsis, textElided, numberOfLaidOutGlyphs, numberOfActualLaidOutGlyphs, numberOfGlyphs, ellipsisPosition, ellipsisLine, numberOfLines, lines);
499 if(0u < numberOfActualLaidOutGlyphs)
501 // Retrieve from the visual model the glyphs and positions.
502 mImpl->mVisualModel->GetGlyphs(glyphs,
504 numberOfLaidOutGlyphs);
506 mImpl->mVisualModel->GetGlyphPositions(glyphPositions,
508 numberOfLaidOutGlyphs);
510 // Get the lines for the given range of glyphs.
511 // The lines contain the alignment offset which needs to be added to the glyph's position.
512 LineIndex firstLineIndex = 0u;
513 Length numberOfLines = 0u;
514 mImpl->mVisualModel->GetNumberOfLines(glyphIndex,
515 numberOfLaidOutGlyphs,
519 Vector<LineRun> lines;
520 lines.Resize(numberOfLines);
521 LineRun* lineBuffer = lines.Begin();
523 mImpl->mVisualModel->GetLinesOfGlyphRange(lineBuffer,
525 numberOfLaidOutGlyphs);
527 // Get the first line for the given glyph range.
528 LineIndex lineIndex = firstLineIndex;
529 LineRun* line = lineBuffer + lineIndex;
531 // Index of the last glyph of the line.
532 GlyphIndex lastGlyphIndexOfLine = (line->isSplitToTwoHalves ? line->glyphRunSecondHalf.glyphIndex + line->glyphRunSecondHalf.numberOfGlyphs : line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs) - 1u;
534 // Add the alignment offset to the glyph's position.
536 minLineOffset = line->alignmentOffset;
537 float penY = line->ascender;
538 for(Length index = 0u; index < numberOfLaidOutGlyphs; ++index)
540 Vector2& position = *(glyphPositions + index);
541 position.x += line->alignmentOffset;
544 if(lastGlyphIndexOfLine == index)
546 penY += -line->descender + line->lineSpacing;
548 // Get the next line.
551 if(lineIndex < numberOfLines)
553 line = lineBuffer + lineIndex;
554 minLineOffset = std::min(minLineOffset, line->alignmentOffset);
556 lastGlyphIndexOfLine = (line->isSplitToTwoHalves ? line->glyphRunSecondHalf.glyphIndex + line->glyphRunSecondHalf.numberOfGlyphs : line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs) - 1u;
558 penY += line->ascender;
563 // Set index where to set Ellipsis according to the selected position of Ellipsis.
564 // Start with this index to replace its glyph by Ellipsis, if the width is not enough, then remove more glyphs.
565 GlyphIndex startIndexOfEllipsis = 0u;
568 switch(ellipsisPosition)
570 case DevelText::EllipsisPosition::START:
572 // It's the fisrt glyph in line.
573 startIndexOfEllipsis = ellipsisLine->glyphRun.glyphIndex;
576 case DevelText::EllipsisPosition::MIDDLE:
578 // It's the second middle of the line in case the line split to two halves.
579 // Otherwise it's It's the last glyph in line (line before all removed lines).
580 startIndexOfEllipsis = ellipsisLine->isSplitToTwoHalves ? (ellipsisLine->glyphRunSecondHalf.glyphIndex) : (ellipsisLine->glyphRun.glyphIndex + ellipsisLine->glyphRun.numberOfGlyphs - 1u);
583 case DevelText::EllipsisPosition::END:
585 // It's the last glyph in line.
586 startIndexOfEllipsis = ellipsisLine->glyphRun.glyphIndex + ellipsisLine->glyphRun.numberOfGlyphs - 1u;
592 if(1u == numberOfLaidOutGlyphs)
594 // not a point try to do ellipsis with only one laid out character.
596 return numberOfLaidOutGlyphs;
601 const LineRun& elidedLine = *ellipsisLine;
603 if((1u == numberOfLines) &&
604 (GetLineHeight(elidedLine, true) > mImpl->mVisualModel->mControlSize.height))
606 // Replace the first glyph with ellipsis glyph
607 auto indexOfFirstGlyph = (ellipsisPosition == DevelText::EllipsisPosition::START) ? startIndexOfEllipsis : 0u;
609 // Regardless where the location of ellipsis,in-case the hight of line is greater than control's height
610 // then replace the first glyph with ellipsis glyph.
612 // Get the first glyph which is going to be replaced and the ellipsis glyph.
613 GlyphInfo& glyphInfo = *(glyphs + indexOfFirstGlyph);
614 const GlyphInfo& ellipsisGlyph = mImpl->mFontClient.GetEllipsisGlyph(mImpl->mFontClient.GetPointSize(glyphInfo.fontId));
616 // Change the 'x' and 'y' position of the ellipsis glyph.
617 Vector2& position = *(glyphPositions + indexOfFirstGlyph);
618 position.x = ellipsisGlyph.xBearing;
619 position.y = mImpl->mVisualModel->mControlSize.height - ellipsisGlyph.yBearing;
621 // Replace the glyph by the ellipsis glyph.
622 glyphInfo = ellipsisGlyph;
624 mImpl->mVisualModel->SetStartIndexOfElidedGlyphs(indexOfFirstGlyph);
625 mImpl->mVisualModel->SetEndIndexOfElidedGlyphs(indexOfFirstGlyph);
626 mImpl->mVisualModel->SetFirstMiddleIndexOfElidedGlyphs(indexOfFirstGlyph);
627 mImpl->mVisualModel->SetSecondMiddleIndexOfElidedGlyphs(indexOfFirstGlyph);
629 numberOfLaidOutGlyphs = 1u;
631 return numberOfLaidOutGlyphs;
634 // Add the ellipsis glyph.
635 Length numberOfRemovedGlyphs = 0u;
636 GlyphIndex indexOfEllipsis = startIndexOfEllipsis;
638 // Tail Mode: start by the end of line.
639 const bool isTailMode = ellipsisPosition == DevelText::EllipsisPosition::END ||
640 (ellipsisPosition == DevelText::EllipsisPosition::MIDDLE && numberOfLines != 1u);
642 // The ellipsis glyph has to fit in the place where the last glyph(s) is(are) removed.
644 glyphs, indexOfEllipsis, numberOfRemovedGlyphs, glyphPositions, mImpl->mFontClient, characterSpacingGlyphRuns, modelCharacterSpacing,
645 calculatedAdvance, textBuffer, glyphToCharacterMapBuffer, numberOfGlyphs, isTailMode, ellipsisLine, numberOfLaidOutGlyphs);
647 RemoveAllGlyphsAfterEllipsisGlyph(
648 ellipsisPosition, numberOfLaidOutGlyphs, numberOfActualLaidOutGlyphs, numberOfRemovedGlyphs, isTailMode, indexOfEllipsis, ellipsisNextLine,
649 ellipsisLine, glyphs, glyphPositions, numberOfGlyphs, startIndexOfEllipsis, mImpl->mVisualModel);
655 return numberOfLaidOutGlyphs;
658 const Vector4* View::GetColors() const
660 if(mImpl->mVisualModel)
662 return mImpl->mVisualModel->mColors.Begin();
668 const ColorIndex* View::GetColorIndices() const
670 if(mImpl->mVisualModel)
672 return mImpl->mVisualModel->mColorIndices.Begin();
678 const Vector4* View::GetBackgroundColors() const
680 if(mImpl->mVisualModel)
682 return mImpl->mVisualModel->mBackgroundColors.Begin();
688 const ColorIndex* View::GetBackgroundColorIndices() const
690 if(mImpl->mVisualModel)
692 return mImpl->mVisualModel->mBackgroundColorIndices.Begin();
698 bool View::IsMarkupBackgroundColorSet() const
700 if(mImpl->mVisualModel)
702 return (mImpl->mVisualModel->mBackgroundColors.Count() > 0);
708 const Vector4& View::GetTextColor() const
710 if(mImpl->mVisualModel)
712 return mImpl->mVisualModel->GetTextColor();
714 return Vector4::ZERO;
717 const Vector2& View::GetShadowOffset() const
719 if(mImpl->mVisualModel)
721 return mImpl->mVisualModel->GetShadowOffset();
723 return Vector2::ZERO;
726 const Vector4& View::GetShadowColor() const
728 if(mImpl->mVisualModel)
730 return mImpl->mVisualModel->GetShadowColor();
732 return Vector4::ZERO;
735 const Vector4& View::GetUnderlineColor() const
737 if(mImpl->mVisualModel)
739 return mImpl->mVisualModel->GetUnderlineColor();
741 return Vector4::ZERO;
744 bool View::IsUnderlineEnabled() const
746 if(mImpl->mVisualModel)
748 return mImpl->mVisualModel->IsUnderlineEnabled();
753 bool View::IsMarkupUnderlineSet() const
755 return (GetNumberOfUnderlineRuns() > 0u);
758 const GlyphInfo* View::GetHyphens() const
760 if(mImpl->mVisualModel)
762 return mImpl->mVisualModel->mHyphen.glyph.Begin();
768 const Length* View::GetHyphenIndices() const
770 if(mImpl->mVisualModel)
772 return mImpl->mVisualModel->mHyphen.index.Begin();
778 Length View::GetHyphensCount() const
780 if(mImpl->mVisualModel)
782 return mImpl->mVisualModel->mHyphen.glyph.Size();
787 float View::GetUnderlineHeight() const
789 if(mImpl->mVisualModel)
791 return mImpl->mVisualModel->GetUnderlineHeight();
796 Text::Underline::Type View::GetUnderlineType() const
798 Text::Underline::Type type = Text::Underline::Type::SOLID;
799 if(mImpl->mVisualModel)
801 type = mImpl->mVisualModel->GetUnderlineType();
806 float View::GetDashedUnderlineWidth() const
809 if(mImpl->mVisualModel)
811 width = mImpl->mVisualModel->GetDashedUnderlineWidth();
816 float View::GetDashedUnderlineGap() const
819 if(mImpl->mVisualModel)
821 gap = mImpl->mVisualModel->GetDashedUnderlineGap();
826 Length View::GetNumberOfUnderlineRuns() const
828 if(mImpl->mVisualModel)
830 return mImpl->mVisualModel->GetNumberOfUnderlineRuns();
836 void View::GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns,
837 UnderlineRunIndex index,
838 Length numberOfRuns) const
840 if(mImpl->mVisualModel)
842 mImpl->mVisualModel->GetUnderlineRuns(underlineRuns,
848 const Vector2& View::GetOutlineOffset() const
850 // TODO : We should support outline offset to editable text.
852 if(mImpl->mVisualModel)
854 return mImpl->mVisualModel->GetOutlineOffset();
857 return Vector2::ZERO;
860 const Vector4& View::GetOutlineColor() const
862 if(mImpl->mVisualModel)
864 return mImpl->mVisualModel->GetOutlineColor();
866 return Vector4::ZERO;
869 uint16_t View::GetOutlineWidth() const
871 if(mImpl->mVisualModel)
873 return mImpl->mVisualModel->GetOutlineWidth();
878 DevelText::EllipsisPosition::Type View::GetEllipsisPosition() const
880 DevelText::EllipsisPosition::Type ellipsisPosition = DevelText::EllipsisPosition::END;
881 if(mImpl->mVisualModel)
883 const VisualModel& model = *mImpl->mVisualModel;
884 ellipsisPosition = model.GetEllipsisPosition();
887 return ellipsisPosition;
890 bool View::IsTextElideEnabled() const
892 bool isTextElideEnabled = false;
894 if(mImpl->mVisualModel)
896 const VisualModel& model = *mImpl->mVisualModel;
897 isTextElideEnabled = model.IsTextElideEnabled();
900 return isTextElideEnabled;
903 GlyphIndex View::GetStartIndexOfElidedGlyphs() const
905 GlyphIndex startIndexOfElidedGlyphs = 0u;
907 if(mImpl->mVisualModel)
909 const VisualModel& model = *mImpl->mVisualModel;
910 startIndexOfElidedGlyphs = model.GetStartIndexOfElidedGlyphs();
913 return startIndexOfElidedGlyphs;
916 GlyphIndex View::GetEndIndexOfElidedGlyphs() const
918 GlyphIndex endIndexOfElidedGlyphs = 0u;
920 if(mImpl->mVisualModel)
922 const VisualModel& model = *mImpl->mVisualModel;
923 endIndexOfElidedGlyphs = model.GetEndIndexOfElidedGlyphs();
926 return endIndexOfElidedGlyphs;
929 GlyphIndex View::GetFirstMiddleIndexOfElidedGlyphs() const
931 GlyphIndex firstMiddleIndexOfElidedGlyphs = 0u;
933 if(mImpl->mVisualModel)
935 const VisualModel& model = *mImpl->mVisualModel;
936 firstMiddleIndexOfElidedGlyphs = model.GetFirstMiddleIndexOfElidedGlyphs();
939 return firstMiddleIndexOfElidedGlyphs;
942 GlyphIndex View::GetSecondMiddleIndexOfElidedGlyphs() const
944 GlyphIndex secondMiddleIndexOfElidedGlyphs = 0u;
946 if(mImpl->mVisualModel)
948 const VisualModel& model = *mImpl->mVisualModel;
949 secondMiddleIndexOfElidedGlyphs = model.GetSecondMiddleIndexOfElidedGlyphs();
952 return secondMiddleIndexOfElidedGlyphs;
955 const Vector4& View::GetStrikethroughColor() const
957 return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetStrikethroughColor() : Vector4::ZERO;
960 bool View::IsStrikethroughEnabled() const
962 return (mImpl->mVisualModel) ? mImpl->mVisualModel->IsStrikethroughEnabled() : false;
965 bool View::IsMarkupStrikethroughSet() const
967 return (GetNumberOfStrikethroughRuns() > 0u);
970 float View::GetStrikethroughHeight() const
972 return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetStrikethroughHeight() : 0.0f;
975 Length View::GetNumberOfStrikethroughRuns() const
977 if(mImpl->mVisualModel)
979 return mImpl->mVisualModel->GetNumberOfStrikethroughRuns();
985 void View::GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns,
986 StrikethroughRunIndex index,
987 Length numberOfRuns) const
989 if(mImpl->mVisualModel)
991 mImpl->mVisualModel->GetStrikethroughRuns(strikethroughRuns,
997 Length View::GetNumberOfBoundedParagraphRuns() const
999 if(mImpl->mLogicalModel)
1001 return mImpl->mLogicalModel->GetNumberOfBoundedParagraphRuns();
1007 const Vector<BoundedParagraphRun>& View::GetBoundedParagraphRuns() const
1009 return mImpl->mLogicalModel->GetBoundedParagraphRuns();
1012 float View::GetCharacterSpacing() const
1014 return mImpl->mVisualModel->GetCharacterSpacing();
1017 const Character* View::GetTextBuffer() const
1019 return mImpl->mLogicalModel->mText.Begin();
1022 const Vector<CharacterIndex>& View::GetGlyphsToCharacters() const
1024 return mImpl->mVisualModel->GetGlyphsToCharacters();
1027 bool View::IsCutoutEnabled() const
1029 if(mImpl->mVisualModel)
1031 return mImpl->mVisualModel->IsCutoutEnabled();
1036 } // namespace Dali::Toolkit::Text