Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26c87cfb authored by Raph Levien's avatar Raph Levien
Browse files

Ignore width of trailing whitespace for computing ellipsis

We used the full width of a line, including trailing spaces, to compute
ellipsis, sometimes causing spurious ellipsization when the space pushed
it past the layout width. This patch uses only the width up to the last
graphing character.

Fix for bug 17186801 "First line of title text is getting truncated even
if there's space on second line"

Change-Id: I49d07c18c8dd1d3b279f591224d23e10645dc8c0
parent d2663684
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -262,6 +262,8 @@ public class StaticLayout extends Layout {
            int fit = paraStart;
            float fitWidth = w;
            int fitAscent = 0, fitDescent = 0, fitTop = 0, fitBottom = 0;
            // same as fitWidth but not including any trailing whitespace
            float fitWidthGraphing = w;

            boolean hasTabOrEmoji = false;
            boolean hasTab = false;
@@ -346,6 +348,9 @@ public class StaticLayout extends Layout {

                    if (w <= width || isSpaceOrTab) {
                        fitWidth = w;
                        if (!isSpaceOrTab) {
                            fitWidthGraphing = w;
                        }
                        fit = j + 1;

                        if (fmTop < fitTop)
@@ -365,7 +370,7 @@ public class StaticLayout extends Layout {
                                breakOpp[breakOppIndex] == j - paraStart + 1;

                        if (isLineBreak) {
                            okWidth = w;
                            okWidth = fitWidthGraphing;
                            ok = j + 1;

                            if (fitTop < okTop)
@@ -426,6 +431,7 @@ public class StaticLayout extends Layout {
                        j = here - 1; // restart j-span loop from here, compensating for the j++
                        ok = fit = here;
                        w = 0;
                        fitWidthGraphing = w;
                        fitAscent = fitDescent = fitTop = fitBottom = 0;
                        okAscent = okDescent = okTop = okBottom = 0;