Skip to content

Commit

Permalink
editor: minor text fixes
Browse files Browse the repository at this point in the history
There are two bugs this PR fixes:
1. The text style of the ellipsis should be the same as the style of the text that's truncated. This is fixed by passing the styleId to the ellipsis text run.
2. When the text is unwrapped, ellipsis should only happen at the last few characters, instead of the whole line. This is fixed by setting x back to 0.0 after the 'do we need ellipsis' check.

Diffs=
4b7454518f editor: minor text fixes (#8787)

Co-authored-by: Susan Wang <[email protected]>
  • Loading branch information
susan101566 and susan101566 committed Dec 20, 2024
1 parent 0f4194c commit c9f80a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
de2a5cbf93851ab109846403b5a17701f72e507d
4b7454518f23f181a02c8a21c95bc0f6b10fb14a
15 changes: 10 additions & 5 deletions src/text/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ bool OrderedLine::buildEllipsisRuns(std::vector<const GlyphRun*>& logicalRuns,

bool ellipsisOverflowed = false;
startGIndex = line.startGlyphIndex;
x = 0.0f;

for (uint32_t i = line.startRunIndex; i < line.endRunIndex + 1; i++)
{
Expand All @@ -189,11 +190,15 @@ bool OrderedLine::buildEllipsisRuns(std::vector<const GlyphRun*>& logicalRuns,

// Get the next shape so we can check if it fits, otherwise keep
// using the last one.
TextRun ellipsisRuns[] = {{ellipsisFont,
ellipsisFontSize,
run.lineHeight,
run.letterSpacing,
(uint32_t)ellipsisCodePoints.size()}};
TextRun ellipsisRuns[] = {{
ellipsisFont,
ellipsisFontSize,
run.lineHeight,
run.letterSpacing,
(uint32_t)ellipsisCodePoints.size(),
0, // default, TextRun.script
run.styleId,
}};
auto nextEllipsisShape =
ellipsisFont->shapeText(ellipsisCodePoints,
Span<TextRun>(ellipsisRuns, 1));
Expand Down

0 comments on commit c9f80a9

Please sign in to comment.