2 * Copyright (c) 2022 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>
38 VisualModelPtr mVisualModel;
39 LogicalModelPtr mLogicalModel;
40 TextAbstraction::FontClient mFontClient; ///< Handle to the font client.
46 mImpl = new View::Impl();
48 mImpl->mFontClient = TextAbstraction::FontClient::Get();
56 void View::SetVisualModel(VisualModelPtr visualModel)
58 mImpl->mVisualModel = visualModel;
61 void View::SetLogicalModel(LogicalModelPtr logicalModel)
63 mImpl->mLogicalModel = logicalModel;
66 const Vector2& View::GetControlSize() const
68 if(mImpl->mVisualModel)
70 return mImpl->mVisualModel->mControlSize;
76 const Vector2& View::GetLayoutSize() const
78 if(mImpl->mVisualModel)
80 return mImpl->mVisualModel->GetLayoutSize();
86 Length View::GetNumberOfGlyphs() const
88 if(mImpl->mVisualModel)
90 const VisualModel& model = *mImpl->mVisualModel;
92 const Length glyphCount = model.mGlyphs.Count();
93 const Length positionCount = model.mGlyphPositions.Count();
95 DALI_ASSERT_DEBUG(positionCount <= glyphCount && "Invalid glyph positions in Model");
97 return (positionCount < glyphCount) ? positionCount : glyphCount;
103 Length View::GetGlyphs(GlyphInfo* glyphs,
104 Vector2* glyphPositions,
105 float& minLineOffset,
106 GlyphIndex glyphIndex,
107 Length numberOfGlyphs) const
109 Length numberOfLaidOutGlyphs = 0u;
110 Length numberOfActualLaidOutGlyphs = 0u;
111 const float modelCharacterSpacing = mImpl->mVisualModel->GetCharacterSpacing();
112 Vector<CharacterIndex>& glyphToCharacterMap = mImpl->mVisualModel->mGlyphsToCharacters;
113 const CharacterIndex* glyphToCharacterMapBuffer = glyphToCharacterMap.Begin();
114 float calculatedAdvance = 0.f;
115 const Character* textBuffer = mImpl->mLogicalModel->mText.Begin();
118 if(mImpl->mVisualModel)
120 // Get the character-spacing runs.
121 const Vector<CharacterSpacingGlyphRun>& characterSpacingGlyphRuns = mImpl->mVisualModel->GetCharacterSpacingGlyphRuns();
123 bool textElided = false;
124 DevelText::EllipsisPosition::Type ellipsisPosition = GetEllipsisPosition();
126 //Reset indices of ElidedGlyphs
127 mImpl->mVisualModel->SetStartIndexOfElidedGlyphs(0u);
128 mImpl->mVisualModel->SetEndIndexOfElidedGlyphs(numberOfGlyphs);
129 mImpl->mVisualModel->SetFirstMiddleIndexOfElidedGlyphs(0u);
130 mImpl->mVisualModel->SetSecondMiddleIndexOfElidedGlyphs(0u);
132 // If ellipsis is enabled, the number of glyphs the layout engine has laid out may be less than 'numberOfGlyphs'.
133 // Check the last laid out line to know if the layout engine elided some text.
135 const Length numberOfLines = mImpl->mVisualModel->mLines.Count();
136 if(numberOfLines > 0u)
138 const LineRun* const lines = mImpl->mVisualModel->mLines.Begin();
140 //Get line of ellipsis
141 const LineRun* ellipsisLine = nullptr;
142 const LineRun* ellipsisNextLine = nullptr;
143 bool hasEllipsis = false;
144 for(Length lineIndex = 0; lineIndex < numberOfLines; lineIndex++)
146 const LineRun* line = (lines + lineIndex);
151 if(lineIndex < numberOfLines - 1u)
153 ellipsisNextLine = (lines + lineIndex + 1u);
159 // If ellipsis is enabled, calculate the number of laid out glyphs.
160 // Otherwise use the given number of glyphs.
164 numberOfLaidOutGlyphs = numberOfGlyphs;
166 if(ellipsisPosition == DevelText::EllipsisPosition::START)
168 numberOfActualLaidOutGlyphs = numberOfGlyphs - ellipsisLine->glyphRun.glyphIndex;
170 else if(ellipsisPosition == DevelText::EllipsisPosition::MIDDLE)
172 numberOfActualLaidOutGlyphs = 0u;
173 for(Length lineIndex = 0u; lineIndex < numberOfLines; lineIndex++)
175 numberOfActualLaidOutGlyphs += lines[lineIndex].glyphRun.numberOfGlyphs + lines[lineIndex].glyphRunSecondHalf.numberOfGlyphs;
178 else // DevelText::EllipsisPosition::END
180 numberOfActualLaidOutGlyphs = ellipsisLine->glyphRun.glyphIndex + ellipsisLine->glyphRun.numberOfGlyphs;
185 numberOfActualLaidOutGlyphs = numberOfLaidOutGlyphs = numberOfGlyphs;
188 if(0u < numberOfActualLaidOutGlyphs)
190 // Retrieve from the visual model the glyphs and positions.
191 mImpl->mVisualModel->GetGlyphs(glyphs,
193 numberOfLaidOutGlyphs);
195 mImpl->mVisualModel->GetGlyphPositions(glyphPositions,
197 numberOfLaidOutGlyphs);
199 // Get the lines for the given range of glyphs.
200 // The lines contain the alignment offset which needs to be added to the glyph's position.
201 LineIndex firstLineIndex = 0u;
202 Length numberOfLines = 0u;
203 mImpl->mVisualModel->GetNumberOfLines(glyphIndex,
204 numberOfLaidOutGlyphs,
208 Vector<LineRun> lines;
209 lines.Resize(numberOfLines);
210 LineRun* lineBuffer = lines.Begin();
212 mImpl->mVisualModel->GetLinesOfGlyphRange(lineBuffer,
214 numberOfLaidOutGlyphs);
216 // Get the first line for the given glyph range.
217 LineIndex lineIndex = firstLineIndex;
218 LineRun* line = lineBuffer + lineIndex;
220 // Index of the last glyph of the line.
221 GlyphIndex lastGlyphIndexOfLine = (line->isSplitToTwoHalves ? line->glyphRunSecondHalf.glyphIndex + line->glyphRunSecondHalf.numberOfGlyphs : line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs) - 1u;
223 // Add the alignment offset to the glyph's position.
225 minLineOffset = line->alignmentOffset;
226 float penY = line->ascender;
227 for(Length index = 0u; index < numberOfLaidOutGlyphs; ++index)
229 Vector2& position = *(glyphPositions + index);
230 position.x += line->alignmentOffset;
233 if(lastGlyphIndexOfLine == index)
235 penY += -line->descender + line->lineSpacing;
237 // Get the next line.
240 if(lineIndex < numberOfLines)
242 line = lineBuffer + lineIndex;
243 minLineOffset = std::min(minLineOffset, line->alignmentOffset);
245 lastGlyphIndexOfLine = (line->isSplitToTwoHalves ? line->glyphRunSecondHalf.glyphIndex + line->glyphRunSecondHalf.numberOfGlyphs : line->glyphRun.glyphIndex + line->glyphRun.numberOfGlyphs) - 1u;
247 penY += line->ascender;
252 // Set index where to set Ellipsis according to the selected position of Ellipsis.
253 // Start with this index to replace its glyph by Ellipsis, if the width is not enough, then remove more glyphs.
254 GlyphIndex startIndexOfEllipsis = 0u;
257 if(ellipsisPosition == DevelText::EllipsisPosition::START)
259 // It's the fisrt glyph in line.
260 startIndexOfEllipsis = ellipsisLine->glyphRun.glyphIndex;
262 else if(ellipsisPosition == DevelText::EllipsisPosition::MIDDLE)
264 // It's the second middle of the line in case the line split to two halves.
265 // Otherwise it's It's the last glyph in line (line before all removed lines).
266 startIndexOfEllipsis = ellipsisLine->isSplitToTwoHalves ? (ellipsisLine->glyphRunSecondHalf.glyphIndex) : (ellipsisLine->glyphRun.glyphIndex + ellipsisLine->glyphRun.numberOfGlyphs - 1u);
268 else // DevelText::EllipsisPosition::END
270 // It's the last glyph in line.
271 startIndexOfEllipsis = ellipsisLine->glyphRun.glyphIndex + ellipsisLine->glyphRun.numberOfGlyphs - 1u;
275 if(1u == numberOfLaidOutGlyphs)
277 // not a point try to do ellipsis with only one laid out character.
279 return numberOfLaidOutGlyphs;
284 const LineRun& elidedLine = *ellipsisLine;
286 if((1u == numberOfLines) &&
287 (GetLineHeight(elidedLine, true) > mImpl->mVisualModel->mControlSize.height))
289 // Replace the first glyph with ellipsis glyph
290 auto indexOfFirstGlyph = (ellipsisPosition == DevelText::EllipsisPosition::START) ? startIndexOfEllipsis : 0u;
292 // Regardless where the location of ellipsis,in-case the hight of line is greater than control's height
293 // then replace the first glyph with ellipsis glyph.
295 // Get the first glyph which is going to be replaced and the ellipsis glyph.
296 GlyphInfo& glyphInfo = *(glyphs + indexOfFirstGlyph);
297 const GlyphInfo& ellipsisGlyph = mImpl->mFontClient.GetEllipsisGlyph(mImpl->mFontClient.GetPointSize(glyphInfo.fontId));
299 // Change the 'x' and 'y' position of the ellipsis glyph.
300 Vector2& position = *(glyphPositions + indexOfFirstGlyph);
301 position.x = ellipsisGlyph.xBearing;
302 position.y = mImpl->mVisualModel->mControlSize.height - ellipsisGlyph.yBearing;
304 // Replace the glyph by the ellipsis glyph.
305 glyphInfo = ellipsisGlyph;
307 mImpl->mVisualModel->SetStartIndexOfElidedGlyphs(indexOfFirstGlyph);
308 mImpl->mVisualModel->SetEndIndexOfElidedGlyphs(indexOfFirstGlyph);
309 mImpl->mVisualModel->SetFirstMiddleIndexOfElidedGlyphs(indexOfFirstGlyph);
310 mImpl->mVisualModel->SetSecondMiddleIndexOfElidedGlyphs(indexOfFirstGlyph);
312 numberOfLaidOutGlyphs = 1u;
314 return numberOfLaidOutGlyphs;
317 // firstPenX, penY and firstPenSet are used to position the ellipsis glyph if needed.
318 float firstPenX = 0.f; // Used if rtl text is elided.
320 bool firstPenSet = false;
322 // Add the ellipsis glyph.
323 bool inserted = false;
324 float removedGlypsWidth = 0.f;
325 Length numberOfRemovedGlyphs = 0u;
326 GlyphIndex indexOfEllipsis = startIndexOfEllipsis;
328 // Tail Mode: start by the end of line.
329 const bool isTailMode = ellipsisPosition == DevelText::EllipsisPosition::END ||
330 (ellipsisPosition == DevelText::EllipsisPosition::MIDDLE && numberOfLines != 1u);
332 // The ellipsis glyph has to fit in the place where the last glyph(s) is(are) removed.
335 const GlyphInfo& glyphToRemove = *(glyphs + indexOfEllipsis);
337 if(0u != glyphToRemove.fontId)
339 // i.e. The font id of the glyph shaped from the '\n' character is zero.
341 // Need to reshape the glyph as the font may be different in size.
342 const GlyphInfo& ellipsisGlyph = mImpl->mFontClient.GetEllipsisGlyph(mImpl->mFontClient.GetPointSize(glyphToRemove.fontId));
346 const Vector2& position = *(glyphPositions + indexOfEllipsis);
348 // Calculates the penY of the current line. It will be used to position the ellipsis glyph.
349 penY = position.y + glyphToRemove.yBearing;
351 // Calculates the first penX which will be used if rtl text is elided.
352 firstPenX = position.x - glyphToRemove.xBearing;
353 if(firstPenX < -ellipsisGlyph.xBearing)
355 // Avoids to exceed the bounding box when rtl text is elided.
356 firstPenX = -ellipsisGlyph.xBearing;
359 removedGlypsWidth = -ellipsisGlyph.xBearing;
364 const float characterSpacing = GetGlyphCharacterSpacing(indexOfEllipsis, characterSpacingGlyphRuns, modelCharacterSpacing);
365 calculatedAdvance = GetCalculatedAdvance(*(textBuffer + (*(glyphToCharacterMapBuffer + indexOfEllipsis))), characterSpacing, glyphToRemove.advance);
366 removedGlypsWidth += std::min(calculatedAdvance, (glyphToRemove.xBearing + glyphToRemove.width));
368 // Calculate the width of the ellipsis glyph and check if it fits.
369 const float ellipsisGlyphWidth = ellipsisGlyph.width + ellipsisGlyph.xBearing;
370 if((ellipsisGlyphWidth < removedGlypsWidth) || (isTailMode ? (indexOfEllipsis == 0u) : (indexOfEllipsis == numberOfGlyphs - 1u)))
372 GlyphInfo& glyphInfo = *(glyphs + indexOfEllipsis);
373 Vector2& position = *(glyphPositions + indexOfEllipsis);
374 position.x -= (0.f > glyphInfo.xBearing) ? glyphInfo.xBearing : 0.f;
376 // Replace the glyph by the ellipsis glyph.
377 glyphInfo = ellipsisGlyph;
379 // Change the 'x' and 'y' position of the ellipsis glyph.
381 if(position.x > firstPenX)
383 position.x = firstPenX + removedGlypsWidth - ellipsisGlyphWidth;
386 position.x += ellipsisGlyph.xBearing;
387 position.y = penY - ellipsisGlyph.yBearing;
395 if(isTailMode && indexOfEllipsis > 0u)
397 // Tail Mode: remove glyphs from startIndexOfEllipsis then decrement indexOfEllipsis, until arrive to index zero.
400 else if(!isTailMode && indexOfEllipsis < numberOfLaidOutGlyphs - 1u)
402 // Not Tail Mode: remove glyphs from startIndexOfEllipsis then increase indexOfEllipsis, until arrive to last index (numberOfGlyphs - 1u).
407 // No space for the ellipsis.
410 ++numberOfRemovedGlyphs;
414 // 'Removes' all the glyphs after the ellipsis glyph.
415 if(ellipsisPosition == DevelText::EllipsisPosition::MIDDLE)
417 //Reduce size, shift glyphs and start from ellipsis glyph
418 numberOfLaidOutGlyphs = numberOfActualLaidOutGlyphs - numberOfRemovedGlyphs;
420 GlyphIndex firstMiddleIndexOfElidedGlyphs = 0u;
421 GlyphIndex secondMiddleIndexOfElidedGlyphs = 0u;
423 bool isOnlySecondHalf = false;
426 // Multi-lines case with MIDDLE
427 // In case the Ellipsis in the end of line,
428 // then this index will be the firstMiddleIndex.
429 // The secondMiddleIndex will be the fisrt index in next line.
430 // But in case there is no line after Ellipsis's line then secondMiddleIndex and endIndex equal firstMiddle
432 // A: are laid out glyphs in line has Ellipsis in the end.
433 // N: are laid out glyphs in lines after removed lines.
434 // R: are removed glyphs.
435 // L: are removed glyphs when removed lines.
436 // AAAAAAAAAAAA...RRR => Here's the firstMiddleIndex (First index after last A)
439 // NNNNNNNNNNNNNN => Here's the secondMiddleIndex (First N)
442 firstMiddleIndexOfElidedGlyphs = indexOfEllipsis;
443 if(ellipsisNextLine != nullptr)
445 secondMiddleIndexOfElidedGlyphs = ellipsisNextLine->glyphRun.glyphIndex;
449 secondMiddleIndexOfElidedGlyphs = firstMiddleIndexOfElidedGlyphs;
450 mImpl->mVisualModel->SetEndIndexOfElidedGlyphs(firstMiddleIndexOfElidedGlyphs);
455 // Single line case with MIDDLE
456 // In case the Ellipsis in the middle of line,
457 // Then the last index in first half will be firstMiddleIndex.
458 // And the indexOfEllipsis will be secondMiddleIndex, which is the first index in second half.
460 // A: are laid out glyphs in first half of line.
461 // N: are laid out glyphs in second half of line.
462 // R: are removed glyphs.
463 // L: re removed glyphs when layouting text
464 // AAAAAAALLLLLLLLLLLRRR...NNNNN
465 // firstMiddleIndex (index of last A)
466 // secondMiddleIndex (index before first N)
468 firstMiddleIndexOfElidedGlyphs = (ellipsisLine->glyphRun.numberOfGlyphs > 0u) ? (ellipsisLine->glyphRun.glyphIndex + ellipsisLine->glyphRun.numberOfGlyphs - 1u) : (ellipsisLine->glyphRun.glyphIndex);
469 secondMiddleIndexOfElidedGlyphs = indexOfEllipsis;
470 isOnlySecondHalf = ellipsisLine->glyphRun.numberOfGlyphs == 0u && ellipsisLine->glyphRunSecondHalf.numberOfGlyphs > 0u;
473 mImpl->mVisualModel->SetFirstMiddleIndexOfElidedGlyphs(firstMiddleIndexOfElidedGlyphs);
474 mImpl->mVisualModel->SetSecondMiddleIndexOfElidedGlyphs(secondMiddleIndexOfElidedGlyphs);
476 // The number of shifted glyphs and shifting positions will be different according to Single-line or Multi-lines.
477 // isOnlySecondHalf will be true when MIDDLE Ellipsis glyph in single line.
480 Length numberOfSecondHalfGlyphs = numberOfLaidOutGlyphs - firstMiddleIndexOfElidedGlyphs;
482 //Copy elided glyphs after the ellipsis glyph.
483 memcpy(glyphs + firstMiddleIndexOfElidedGlyphs, glyphs + secondMiddleIndexOfElidedGlyphs, numberOfSecondHalfGlyphs * sizeof(GlyphInfo));
484 memcpy(glyphPositions + firstMiddleIndexOfElidedGlyphs, glyphPositions + secondMiddleIndexOfElidedGlyphs, numberOfSecondHalfGlyphs * sizeof(Vector2));
488 Length numberOfSecondHalfGlyphs = numberOfLaidOutGlyphs - firstMiddleIndexOfElidedGlyphs + 1u;
490 //Copy elided glyphs after the ellipsis glyph.
491 memcpy(glyphs + firstMiddleIndexOfElidedGlyphs + 1u, glyphs + secondMiddleIndexOfElidedGlyphs, numberOfSecondHalfGlyphs * sizeof(GlyphInfo));
492 memcpy(glyphPositions + firstMiddleIndexOfElidedGlyphs + 1u, glyphPositions + secondMiddleIndexOfElidedGlyphs, numberOfSecondHalfGlyphs * sizeof(Vector2));
495 else if(ellipsisPosition == DevelText::EllipsisPosition::START)
497 numberOfLaidOutGlyphs = numberOfActualLaidOutGlyphs - numberOfRemovedGlyphs;
498 //Copy elided glyphs after the ellipsis glyph.
499 memcpy(glyphs, glyphs + startIndexOfEllipsis + numberOfRemovedGlyphs, numberOfLaidOutGlyphs * sizeof(GlyphInfo));
500 memcpy(glyphPositions, glyphPositions + startIndexOfEllipsis + numberOfRemovedGlyphs, numberOfLaidOutGlyphs * sizeof(Vector2));
501 mImpl->mVisualModel->SetStartIndexOfElidedGlyphs(indexOfEllipsis);
503 else // DevelText::EllipsisPosition::END
505 numberOfLaidOutGlyphs = numberOfActualLaidOutGlyphs - numberOfRemovedGlyphs;
506 mImpl->mVisualModel->SetEndIndexOfElidedGlyphs(indexOfEllipsis);
513 return numberOfLaidOutGlyphs;
516 const Vector4* const View::GetColors() const
518 if(mImpl->mVisualModel)
520 return mImpl->mVisualModel->mColors.Begin();
526 const ColorIndex* const View::GetColorIndices() const
528 if(mImpl->mVisualModel)
530 return mImpl->mVisualModel->mColorIndices.Begin();
536 const Vector4* const View::GetBackgroundColors() const
538 if(mImpl->mVisualModel)
540 return mImpl->mVisualModel->mBackgroundColors.Begin();
546 const ColorIndex* const View::GetBackgroundColorIndices() const
548 if(mImpl->mVisualModel)
550 return mImpl->mVisualModel->mBackgroundColorIndices.Begin();
556 bool const View::IsMarkupBackgroundColorSet() const
558 if(mImpl->mVisualModel)
560 return (mImpl->mVisualModel->mBackgroundColors.Count() > 0);
566 const Vector4& View::GetTextColor() const
568 if(mImpl->mVisualModel)
570 return mImpl->mVisualModel->GetTextColor();
572 return Vector4::ZERO;
575 const Vector2& View::GetShadowOffset() const
577 if(mImpl->mVisualModel)
579 return mImpl->mVisualModel->GetShadowOffset();
581 return Vector2::ZERO;
584 const Vector4& View::GetShadowColor() const
586 if(mImpl->mVisualModel)
588 return mImpl->mVisualModel->GetShadowColor();
590 return Vector4::ZERO;
593 const Vector4& View::GetUnderlineColor() const
595 if(mImpl->mVisualModel)
597 return mImpl->mVisualModel->GetUnderlineColor();
599 return Vector4::ZERO;
602 bool View::IsUnderlineEnabled() const
604 if(mImpl->mVisualModel)
606 return mImpl->mVisualModel->IsUnderlineEnabled();
611 const GlyphInfo* View::GetHyphens() const
613 if(mImpl->mVisualModel)
615 return mImpl->mVisualModel->mHyphen.glyph.Begin();
621 const Length* View::GetHyphenIndices() const
623 if(mImpl->mVisualModel)
625 return mImpl->mVisualModel->mHyphen.index.Begin();
631 Length View::GetHyphensCount() const
633 if(mImpl->mVisualModel)
635 return mImpl->mVisualModel->mHyphen.glyph.Size();
640 float View::GetUnderlineHeight() const
642 if(mImpl->mVisualModel)
644 return mImpl->mVisualModel->GetUnderlineHeight();
649 Text::Underline::Type View::GetUnderlineType() const
651 Text::Underline::Type type = Text::Underline::Type::SOLID;
652 if(mImpl->mVisualModel)
654 type = mImpl->mVisualModel->GetUnderlineType();
659 float View::GetDashedUnderlineWidth() const
662 if(mImpl->mVisualModel)
664 width = mImpl->mVisualModel->GetDashedUnderlineWidth();
669 float View::GetDashedUnderlineGap() const
672 if(mImpl->mVisualModel)
674 gap = mImpl->mVisualModel->GetDashedUnderlineGap();
679 Length View::GetNumberOfUnderlineRuns() const
681 if(mImpl->mVisualModel)
683 return mImpl->mVisualModel->GetNumberOfUnderlineRuns();
689 void View::GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns,
690 UnderlineRunIndex index,
691 Length numberOfRuns) const
693 if(mImpl->mVisualModel)
695 mImpl->mVisualModel->GetUnderlineRuns(underlineRuns,
701 const Vector4& View::GetOutlineColor() const
703 if(mImpl->mVisualModel)
705 return mImpl->mVisualModel->GetOutlineColor();
707 return Vector4::ZERO;
710 uint16_t View::GetOutlineWidth() const
712 if(mImpl->mVisualModel)
714 return mImpl->mVisualModel->GetOutlineWidth();
719 DevelText::EllipsisPosition::Type View::GetEllipsisPosition() const
721 DevelText::EllipsisPosition::Type ellipsisPosition = DevelText::EllipsisPosition::END;
722 if(mImpl->mVisualModel)
724 const VisualModel& model = *mImpl->mVisualModel;
725 ellipsisPosition = model.GetEllipsisPosition();
728 return ellipsisPosition;
731 bool View::IsTextElideEnabled() const
733 bool isTextElideEnabled = false;
735 if(mImpl->mVisualModel)
737 const VisualModel& model = *mImpl->mVisualModel;
738 isTextElideEnabled = model.IsTextElideEnabled();
741 return isTextElideEnabled;
744 GlyphIndex View::GetStartIndexOfElidedGlyphs() const
746 GlyphIndex startIndexOfElidedGlyphs = 0u;
748 if(mImpl->mVisualModel)
750 const VisualModel& model = *mImpl->mVisualModel;
751 startIndexOfElidedGlyphs = model.GetStartIndexOfElidedGlyphs();
754 return startIndexOfElidedGlyphs;
757 GlyphIndex View::GetEndIndexOfElidedGlyphs() const
759 GlyphIndex endIndexOfElidedGlyphs = 0u;
761 if(mImpl->mVisualModel)
763 const VisualModel& model = *mImpl->mVisualModel;
764 endIndexOfElidedGlyphs = model.GetEndIndexOfElidedGlyphs();
767 return endIndexOfElidedGlyphs;
770 GlyphIndex View::GetFirstMiddleIndexOfElidedGlyphs() const
772 GlyphIndex firstMiddleIndexOfElidedGlyphs = 0u;
774 if(mImpl->mVisualModel)
776 const VisualModel& model = *mImpl->mVisualModel;
777 firstMiddleIndexOfElidedGlyphs = model.GetFirstMiddleIndexOfElidedGlyphs();
780 return firstMiddleIndexOfElidedGlyphs;
783 GlyphIndex View::GetSecondMiddleIndexOfElidedGlyphs() const
785 GlyphIndex secondMiddleIndexOfElidedGlyphs = 0u;
787 if(mImpl->mVisualModel)
789 const VisualModel& model = *mImpl->mVisualModel;
790 secondMiddleIndexOfElidedGlyphs = model.GetSecondMiddleIndexOfElidedGlyphs();
793 return secondMiddleIndexOfElidedGlyphs;
796 const Vector4& View::GetStrikethroughColor() const
798 return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetStrikethroughColor() : Vector4::ZERO;
801 bool View::IsStrikethroughEnabled() const
803 return (mImpl->mVisualModel) ? mImpl->mVisualModel->IsStrikethroughEnabled() : false;
806 float View::GetStrikethroughHeight() const
808 return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetStrikethroughHeight() : 0.0f;
811 Length View::GetNumberOfStrikethroughRuns() const
813 if(mImpl->mVisualModel)
815 return mImpl->mVisualModel->GetNumberOfStrikethroughRuns();
821 void View::GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns,
822 StrikethroughRunIndex index,
823 Length numberOfRuns) const
825 if(mImpl->mVisualModel)
827 mImpl->mVisualModel->GetStrikethroughRuns(strikethroughRuns,
833 Length View::GetNumberOfBoundedParagraphRuns() const
835 if(mImpl->mLogicalModel)
837 return mImpl->mLogicalModel->GetNumberOfBoundedParagraphRuns();
843 const Vector<BoundedParagraphRun>& View::GetBoundedParagraphRuns() const
845 return mImpl->mLogicalModel->GetBoundedParagraphRuns();
848 Length View::GetNumberOfCharacterSpacingGlyphRuns() const
850 return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetNumberOfCharacterSpacingGlyphRuns() : 0u;
853 const Vector<CharacterSpacingGlyphRun>& View::GetCharacterSpacingGlyphRuns() const
855 return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetCharacterSpacingGlyphRuns() : GetEmptyCharacterSpacingGlyphRuns();
858 const float View::GetCharacterSpacing() const
860 return (mImpl->mVisualModel) ? mImpl->mVisualModel->GetCharacterSpacing() : 0.f;
863 const Character* View::GetTextBuffer() const
865 return (mImpl->mVisualModel) ? mImpl->mLogicalModel->mText.Begin() : nullptr;
868 const Vector<CharacterIndex>& View::GetGlyphsToCharacters() const
870 return mImpl->mVisualModel->GetGlyphsToCharacters();
875 } // namespace Toolkit