diff options
author | Raph Levien <raph@google.com> | 2015-04-22 15:31:29 -0700 |
---|---|---|
committer | Raph Levien <raph@google.com> | 2015-04-22 15:31:29 -0700 |
commit | 68ae337aa05f598af18b09fe4125146d4d67db83 (patch) | |
tree | bf75c1b6b534d1fca4a517d5c35374176a73623f /libs | |
parent | 40beb7744a61248de82a6077996c83c14e0122c2 (diff) | |
download | android_frameworks_minikin-68ae337aa05f598af18b09fe4125146d4d67db83.tar.gz android_frameworks_minikin-68ae337aa05f598af18b09fe4125146d4d67db83.tar.bz2 android_frameworks_minikin-68ae337aa05f598af18b09fe4125146d4d67db83.zip |
Don't include trailing newline in width for line breaking
In a paragraph with a trailing newline, the width of the newline
character was included in the line width for breaking purposes,
basically as if it were a non-breaking space. This caused a
discrepancy, where Layout.getDesiredWidth() suggested that the text
would fit in a single line, but StaticLayout would break it because of
the added width of the newline character.
The proposed fix is simply to consider newline to be a space that
disappears at the end of a line.
Bug: 20152308
Change-Id: I539574c5b8ea892c8ed6aca6c59e90ccdf74a680
Diffstat (limited to 'libs')
-rw-r--r-- | libs/minikin/LineBreaker.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libs/minikin/LineBreaker.cpp b/libs/minikin/LineBreaker.cpp index f4201cb..88190ff 100644 --- a/libs/minikin/LineBreaker.cpp +++ b/libs/minikin/LineBreaker.cpp @@ -84,11 +84,12 @@ void LineBreaker::setIndents(const std::vector<float>& indents) { } // This function determines whether a character is a space that disappears at end of line. -// It is the Unicode set: [[:General_Category=Space_Separator:]-[:Line_Break=Glue:]] +// It is the Unicode set: [[:General_Category=Space_Separator:]-[:Line_Break=Glue:]], +// plus '\n'. // Note: all such characters are in the BMP, so it's ok to use code units for this. static bool isLineEndSpace(uint16_t c) { - return c == ' ' || c == 0x1680 || (0x2000 <= c && c <= 0x200A && c != 0x2007) || c == 0x205F || - c == 0x3000; + return c == '\n' || c == ' ' || c == 0x1680 || (0x2000 <= c && c <= 0x200A && c != 0x2007) || + c == 0x205F || c == 0x3000; } // Ordinarily, this method measures the text in the range given. However, when paint |