History log of /frameworks/base/core/java/android/text/StaticLayout.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
d29bdb266d54b4551f42776bb790e80147a279d0 06-Feb-2015 Neil Fuller <nfuller@google.com> Avoid static initialization of Layout from TextUtils

This works around a bug in standalone (e.g. non-Zygote)
runtimes when a device is attached to a host that is running
DDM.

There is a race condition:

When the runtime receives a HELLO from DDM it calls
TextUtils.isEmpty().

Calling any TextUtils methods statically initializes
Layout. Layout has dependencies on other classes, which in
turn have dependencies on native methods that are not always
registered when the call takes place. Registration and DDM
handling are done in separate threads.

This is not a fix, merely a workaround until the race can
be resolved.

Bug: 18081539
Change-Id: If1bd3de6597bc93da381c8f86dacf40156449561
/frameworks/base/core/java/android/text/StaticLayout.java
0e3c5e827235911d33312e431975533f046421e7 04-Dec-2014 Raph Levien <raph@google.com> Fix off-by-one error in computeEllipsis

In the Truncate.MIDDLE case, when the line is less than half the layout
width, the computeEllipsis logic could go past the left edge of the
string. This patch fixes the off-by-one and avoids the resulting index
out of bounds crash, and also changes the behavior so that when
ellipsizing at the middle, the string to the end of the paragraph is
taken into account.

Bug: 18508627
Change-Id: I24be09c23a5aa158791a9717419307613b8a22e8
/frameworks/base/core/java/android/text/StaticLayout.java
396879f3f88e6384588c421c7e57ceef932aad59 17-Nov-2014 Raph Levien <raph@google.com> Fix missing ellipsis when just one character is truncated

The "moreChars" test in StaticLayout's generate method would evaluate to
false when the last character in a word caused the break. This in turn
suppressed the ellipsis in this case. The proposed fix is always to set
moreChars true in the code path where the line is broken because more
text wouldn't fit.

Bug: 17738112
Change-Id: Ifa1a69841ca952da4d1937dc8326778179b026b3
/frameworks/base/core/java/android/text/StaticLayout.java
26c87cfb584d4533c9b47f7cbf75f6921c52b928 28-Aug-2014 Raph Levien <raph@google.com> 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
/frameworks/base/core/java/android/text/StaticLayout.java
ab08c6d38ab2e575f809ca8ce4c7f095e49d258c 08-Aug-2014 Anish Athalye <aathalye@google.com> Make LeadingMarginSpan2 behavior more consistent

This addresses b/16486549.

This change updates public documentation to specify the behavior of
LeadingMarginSpan2s. This change specifies what happens when a
LeadingMarginSpan2 is combined with other LeadingMarginSpans. This
behavior was not previously documented.

LeadingMarginSpan2s specify the number of lines used for the leading
margin. When laying out and rendering, for all LeadingMarginSpans, the
first line margin is applied for the number of lines specified by the
LeadingMarginSpan2.

Previously, this behavior was slightly buggy -- the LeadingMarginSpan2
affected all LeadingMarginSpans when laying out text, but not when
rendering.

This change is designed to cause the least amount of breakage in
existing code while achieving consistency with the way
LeadingMarginSpan2 is handled in layout and drawing.

For the most common use of LeadingMarginSpan2 -- getting a multi-line
first margin in the first paragraph of text in a layout -- this should
cause no change in behavior. For any other uses, the old (buggy)
implementation most likely did not exhibit correct behavior to begin
with, so developers were most likely not relying on that functionality.

Change-Id: I6f69df09c0130e703458e65bf3eaac4a905df56e
/frameworks/base/core/java/android/text/StaticLayout.java
9cd3bccdb23bfb06da8ac19a44b4216039699ff9 27-Jun-2014 Anish Athalye <aathalye@google.com> Fix line breaking for clusters in narrow views

Clusters were broken incorrectly when in narrow views (when the width of
the cluster was greater than the width of a view). Also, out() calls
were modifying fm, so clusters that were too wide were not positioned
correctly.

Change-Id: I521f8dc6338f5f1de6858af3f0c0bd320aa46bc0
/frameworks/base/core/java/android/text/StaticLayout.java
88b5b0be887fc5dc3b0b879b4179dde200d2e4d6 24-Jun-2014 Anish Athalye <aathalye@google.com> Implement line breaking using ICU break iterator

Change-Id: I4ad98757aa2eab5dbc2ae44c0391e900ef20c4d0
/frameworks/base/core/java/android/text/StaticLayout.java
54dacbe7ca6d8a8c71d601fcf773e7b27eba3a53 29-Apr-2014 Yuling Liang <yulingliang@google.com> am 3914a33c: am 26a5c2dd: Merge "Followon fix for 14276128 Clipping at bottom of TextView" into klp-modular-dev

* commit '3914a33c01102f5de51e33d006c0aeedf2693af0':
Followon fix for 14276128 Clipping at bottom of TextView
d97b097a5b7a906e8d30c6d3b0f41c55650ce7a9 24-Apr-2014 Raph Levien <raph@google.com> Followon fix for 14276128 Clipping at bottom of TextView

The previous fix did not work when the text was ellipsized, because the
test for whether the line was the last line was incorrect. The new test
handles both the end of the buffer and the case where it is the last
line because of ellipsizing.

So this should be the proper fix for bug 14276128 Clipping at bottom of
TextView when lineSpacingMultiplier < 1

This version of the patch also handles the single-line case (which is
computed in BoringLayout rather than StaticLayout).

Change-Id: I88791acc2aa493cc8c599b374f4d213571260b4b
/frameworks/base/core/java/android/text/StaticLayout.java
2be1f8c3f4d338c7b7c73bb642bc410ef27c8ee4 25-Apr-2014 Yuling Liang <yulingliang@google.com> am 69a9d925: am eea94f06: Merge "Revert "Followon fix for 14276128 Clipping at bottom of TextView"" into klp-modular-dev

* commit '69a9d92502428a4cf6eb6b5bf6577d9e525796a2':
Revert "Followon fix for 14276128 Clipping at bottom of TextView"
10973c777648a5893f9c668d2675061f359c223d 25-Apr-2014 Yuling Liang <yulingliang@google.com> Revert "Followon fix for 14276128 Clipping at bottom of TextView"

This reverts commit a10e19845ce76c0e4dd38018c84b83c9255dc9fe.

Change-Id: I6d40451c9eb6285859e16d251b55947663a3553a
/frameworks/base/core/java/android/text/StaticLayout.java
ec2b7d6dd7caa8ad14de90c3d2da5a3f66f46050 25-Apr-2014 Yuling Liang <yulingliang@google.com> am 60f8349b: am 243e551a: Merge "Followon fix for 14276128 Clipping at bottom of TextView" into klp-modular-dev

* commit '60f8349b9819130e81e28106a35bf3362d337045':
Followon fix for 14276128 Clipping at bottom of TextView
a10e19845ce76c0e4dd38018c84b83c9255dc9fe 24-Apr-2014 Raph Levien <raph@google.com> Followon fix for 14276128 Clipping at bottom of TextView

The previous fix did not work when the text was ellipsized, because the
test for whether the line was the last line was incorrect. The new test
handles both the end of the buffer and the case where it is the last
line because of ellipsizing.

So this should be the proper fix for bug 14276128 Clipping at bottom of
TextView when lineSpacingMultiplier < 1

Change-Id: Iac5c96f2273142031c18a27f504f7d6d5fcf823e
/frameworks/base/core/java/android/text/StaticLayout.java
79cb5505a97a0465fb849dc20dcaf3dd2f608c9f 24-Apr-2014 Raph Levien <raph@google.com> am 07bed492: am e4ee0e31: Merge "Fix bug 14276128 Clipping at bottom of TextView" into klp-modular-dev

* commit '07bed4921a05e717a4b7f10a25e3830e346426b7':
Fix bug 14276128 Clipping at bottom of TextView
936df680166bd0cd6146f1a0c8fa8ad9b807f794 24-Apr-2014 Raph Levien <raph@google.com> Fix bug 14276128 Clipping at bottom of TextView

Avoid applying "extra" linespacing to the last line of a layout, because
when that is negative, it causes clipping.

Change-Id: I4cc8792fd3444e4118604cc3d0f816d59dfc1e74
/frameworks/base/core/java/android/text/StaticLayout.java
63b3d8c62ef24121f40b2262e89b3f37527beab3 04-Apr-2014 Raph Levien <raph@google.com> Fix extra text appearing after ellipsis

This is a fix for bug 7615701 TextView: calling setText with long
strings causes ellipsize to not work correctly. The problem is that the
"break" when the last line was ellipsized did not fully break out of
both loops of the processing logic, but only the inner loop. This
caused the outer loop to restart at the next span, causing the next span
boundary to overwrite the line end of the last visible line.

The fix simply returns from the function in that case, as there is no
further processing needing to be done.

Change-Id: I5b34233ffba6f0f6f1c12b9565b4fc53e83a4892
/frameworks/base/core/java/android/text/StaticLayout.java
776abc24cdd18610232a50b997cce3cffa74609b 07-Mar-2014 Adam Lesinski <adamlesinski@google.com> Uses VMRuntime.newUnpaddedArray for ideal array sizes

Bug:13028925

Change-Id: I0a9301248b10a339afbdc5e4ffe3310ac4fa1fb7
/frameworks/base/core/java/android/text/StaticLayout.java
e631889e1ae7edc6a2fae495ba504f85820b6a4b 19-Jun-2013 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #9073962 - Carret is still on the left with an empty EditText in Arabic Locale

- fix StaticLayout special case with empty string or new line

Change-Id: Icb51feedce49db661ed17b6907eb0db83d0b763c
/frameworks/base/core/java/android/text/StaticLayout.java
8d087c349f0a3b7946a95869562f020892d47a86 29-Mar-2013 Raph Levien <raph@google.com> Make zero width space a line breaker

This patch makes ZWSP (U+200B, zero width space) a potential line break
in text layouts. This is a fix for bug 8501809.

Change-Id: I18c1f8464e6c821ff75f819141bacc714a878700
/frameworks/base/core/java/android/text/StaticLayout.java
7c3255f14f83afb00da32aede43664e16da51f53 24-Aug-2012 Raph Levien <raph@google.com> Fix bug 7054190 line breaks at inappropriate places

We were doing line breaks after punctuation as long as they weren't
surrounded by digits. This is a misinterpretation of the Unicode line
breaking algorithm. Punctuation (class IS) is not hugely different than
the default classes (NU and AL) - there are breaks after punctuation
that are allowed (for example, followed by an open parenthesis), but
we're not implementing the algorithm with anything near that level of
fidelity.

The long term fix is to really implement the algorithm. In the shorter
term, the easiest thing to do is to remove the special case altogether.

Change-Id: Ic4dc3216c2a4191fbb7cfa06e9dc038d1a56398c
/frameworks/base/core/java/android/text/StaticLayout.java
81541491946bfc4f2e26c171b4ebff4249dca51c 27-Jun-2012 Gilles Debunne <debunne@google.com> Better handling of spaces at ends of lines in StaticLayout.

Skipping spaces at ends of line used to be done only when ok != here
(a potential line break was found).

Moved this logic up one level to handle all cases.

Also moved maxLine test in the block that actually adds a new line.

Updated the unit tests accordingly.

Change-Id: Ib10bc838b1ffa5b8a60259ea4b622d9fecb2ec70
/frameworks/base/core/java/android/text/StaticLayout.java
badf5a9442e639dc6ae2c4794c202143f6d2f16d 19-Jun-2012 Gilles Debunne <debunne@google.com> Merge "Fixed text rendering issue with spans." into jb-dev
cd943a7a013952af9b7286fd506fd63bf0993ac1 08-Jun-2012 Gilles Debunne <debunne@google.com> Fixed text rendering issue with spans.

Bug 6598784

The algorithm uses three imbricated loops:
- paragraphs
- span regions (called "blocks" in that description) in these
- characters in these

We can ignore the paragraphs and assume paraStart==0.

The span region loop cuts the text into blocks of text which share
the same set of MetricAffectingSpan spans applied to them. Note that
spanStart and spanEnd represent such a range, and not necessarily an
actual span range.

The third loop then iterates over the characters of these blocks, and creates
a new line (calling out() as soon as the width has been reached.

The core of the problem comes from the 'nextSpanStart' variable.
It is used to restart the block loop from a previous position in case
a line has been created that does not intersect with the current block.

However, in case the current block is larger than the width of the text,
the character loop is going to create other lines of text before we exit the
j-loop. Going back to the block loop, we reset spanStart to the nextSpanStart,
which may be too far back in the text. As a result, the same range of characters
is measured again.

The (spanStart == spanEnd) test was used to handle the case where
nextSpanStart was indeed assigned to a value different than spanEnd.

This fix simplifies this logic and removes the nextSpanStart variable:

When the created line ends before the current block (here < spanStart), we
immediately exit the character loop, re-starting the block loop from the
current position.

Patch 4: added a fix in measured to handle overlapping character ranges.

Change-Id: Ie71b3cf4018b332e335ea916fef08acb43a6679e
/frameworks/base/core/java/android/text/StaticLayout.java
8d44fff7e62f77c3b3072a96712cc1389e63ca64 14-Jun-2012 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #6661824 Hebrew Text can be clipped

- use the correct ellipsis char in both measurement and rendered string

Change-Id: Ia00285fc16da528f18702719026503b5d0610642
/frameworks/base/core/java/android/text/StaticLayout.java
34a126e51aaf22e32c7af808ec6b5a0c41ae3311 01-Mar-2012 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #3389545 android:ellipsize="end" doesn't work without using android:singleLine="true" which is deprecated

- take care of single line case too

Change-Id: I73c3dcb96f22241b35d7cbaf43cd9bd46a4abcaa
/frameworks/base/core/java/android/text/StaticLayout.java
d300e75eff0d5e54390400cbd3f80dc4cea8b617 17-Oct-2011 Gilles Debunne <debunne@google.com> Wrong word cut at end of lines with spaces

Bug 5185017: when the line length is exceeded at a space character,
we use the previous ok width, and the last word is wrapped to next line
although it fits.

This back-track also generates problem with the span parsing, where the
spanStart indexes are no longer monotonuously increasing.

Plus some refactoring in this code (unused parameters, calls to out())

Change-Id: Ia8cd310a732752af3bd370bf0a16db23d40e83f2
/frameworks/base/core/java/android/text/StaticLayout.java
ad0b051b133baf92f199c96a8ac1e81b3393190c 05-Oct-2011 Fabrice Di Meglio <fdimeglio@google.com> Revert "Fix bug #5387832 [UI/Visual] Address of the website is not displayed properly(second line of the address is partly shown)"

This reverts commit a130e5f59dc6b2117e4c1a8ffef54828e9ea44c7
/frameworks/base/core/java/android/text/StaticLayout.java
a130e5f59dc6b2117e4c1a8ffef54828e9ea44c7 29-Sep-2011 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #5387832 [UI/Visual] Address of the website is not displayed properly(second line of the address is partly shown)

- make DynamicLayout honor max lines
- make StaticLayout.generate() take maxLines as a parameter instead of using the field mMaximumVisibleLineCount

Change-Id: I9eafb1be4b8bb2aa881514955a6903f559cb6a1e
/frameworks/base/core/java/android/text/StaticLayout.java
cb332649e44db86ff8b4e7f006db4bbfd82fed55 24-Sep-2011 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #5366547 TruncateAt.MARQUEE should be replaces with "two dot" ellipsis on hardware that dont support MARQUEE

- introduce TruncateAt.END_SMALL
- code refactoring for suppressing use of hardcoded constants

Change-Id: I70e24857cd5d6bd012a743cbc0ba46fbd06d5457
/frameworks/base/core/java/android/text/StaticLayout.java
aef455fd5b4c667267deb050bc7997e737b7507e 30-Aug-2011 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #5197549 android.text.cts.StaticLayoutTest#testGetEllipsisCount fails on IRK49E mysid-userdebug

- make the ellipsizing condition easier to read
- allow ellipsizing only and only if
- not MARQUEE
- single line
- END only on the last visible line when multiple lines

Change-Id: I6b08e4a735ebc4875a208f0538d9cf937240316e
/frameworks/base/core/java/android/text/StaticLayout.java
8059e0903e36cbb5cf8b5c5d5d653acc9bbc8402 11-Aug-2011 Fabrice Di Meglio <fdimeglio@google.com> Fix bug #3388534 Long file names are improperly displayed when played

- force ellipsising when there are more lines found than maxLines
- do not care about lines when we have reached maxLines
- also fix relayouting when changing maxLines thru setMaxLines()
- do not allow START / MIDDLE ellipsis when there are multiple lines
(and print a log accordingly)

Change-Id: I90f5a7f5200a220aceee01fb7300bec2c4c3a075
/frameworks/base/core/java/android/text/StaticLayout.java
e5ea4403ce58982522554b7ff23f41e6551923c1 01-Aug-2011 Romain Guy <romainguy@google.com> Plug memory leak in EditText.

Change-Id: I0b42c23ceeaa958d02255945c35ff6807c177114
/frameworks/base/core/java/android/text/StaticLayout.java
cb379120456d8065d742021fc5c66748fc8a11a8 07-Jul-2011 Doug Felt <dougfelt@google.com> Implement textDirection heuristic selection.

Change-Id: I2fcf18de573f2d66494fa5ed61e4273c3c6078c7
/frameworks/base/core/java/android/text/StaticLayout.java
1e3ac18e7ad03e02819f3e1a89d6a80a2bb7645f 08-Mar-2011 Gilles Debunne <debunne@google.com> Empty spans are not considered in text layout/rendering process.

Bug http://code.google.com/p/android/issues/detail?id=14786

Empty spans are affecting the text before and after them. See the
comment in TextUtils.removeEmptySpans for details.

Change-Id: I40376c32fd56a17efde6219f9b2593e4b4ab1ba1
/frameworks/base/core/java/android/text/StaticLayout.java
f3fa0cdbaea109b114f7facbb5d42de3fc12bbc8 03-Feb-2011 Gilles Debunne <debunne@google.com> Bugfixes in StaticLayout.

Bug 3422121

With ellipsize, lines starting with a very long word that does not
fit inside the width were simply ignored. Cut the long word instead.

start - widthStart index offset shift in BiDi.

The original ellipsize-end patch that added '...' after the last
word on end-ellipsized lines has been punted in favor of a true
ellipsize support in I.

I believe the StaticLayout calculateEllipsise is a no-op since textwidth <= avail
by construction: fitWidth and okwidth are < outerWidth. The only exception is the
paraEnd != here case in generate (when not a single character fits in width).
This case is exercised by StaticLayoutTest in cts (width of 8 pixels) and revealed
an offset error in widstart.

All in all, it looks like this code was probably never really tested. I tried some
typical text configuration to make sure these changes improved the situation.

Change-Id: Ibee410bd7db453abf93e10e8beb844eae998922c
/frameworks/base/core/java/android/text/StaticLayout.java
121c82c8130c2658f73fb19f3a62eb88c8679968 16-Feb-2011 Fabrice Di Meglio <fdimeglio@google.com> Code cleaning

- remove unused local variables
- add char constants
- some variables renaming to be more understandable

Change-Id: Id54dd671b1449cca6463bf77160dc72c8bf0c805
/frameworks/base/core/java/android/text/StaticLayout.java
be46d1456beb7e2f3e8b82bda2d0a5023db3debd 05-Feb-2011 Paul Eastham <eastham@google.com> Revert "Fix for StaticLayout bug with ellipsized text"

This reverts commit bbc910f229dec45fa7481a62fbf051f7ff3130e7.
/frameworks/base/core/java/android/text/StaticLayout.java
bbc910f229dec45fa7481a62fbf051f7ff3130e7 04-Feb-2011 Gilles Debunne <debunne@google.com> Fix for StaticLayout bug with ellipsized text

This fixes the test, but I believe this class still needs a lot of fixing.

Change-Id: Ib6386196908ea8432b175d6994f9299778a322d2
/frameworks/base/core/java/android/text/StaticLayout.java
0a4db3c5270440eeb7e4e44a7029926e239ec3bd 14-Jan-2011 Gilles Debunne <debunne@google.com> Pixel were missing on the last line of text when using MaxLines.

Bug 3295544

Only the last line of text includes the bottomPadding (extra line
spacing below the characters' descent. When The text is clipped using
maxLines, the desired height correctly added this value, but getLineTop
and getLineDescent are also used when the layout is drawn.

The fix is to make the layout aware of its clipping so that these
values are correctly updated.

Change-Id: I703656cf45022d34a90f55f0ed8fc5e4b30f80b1
/frameworks/base/core/java/android/text/StaticLayout.java
d434d2334d2362f77d3a3fb0b1f788f667039bbf 05-Jan-2011 Gilles Debunne <debunne@google.com> MaxLines is respected in TextViews, even when ellipsize is set to end.

Bug 3322607

Re-applying the revert that fixed the ANR (https://android-git.corp.google.com/g/#change,87129),
whith an updated here value that seems to fix the problem.

This layout code is pretty involved, with destabilizing variable names and
uses. Althought I tested it, this fix is not 100% garanteed.

Change-Id: I1f4b09b329fb8a328ae8ab26ae472e343453beda
/frameworks/base/core/java/android/text/StaticLayout.java
4cf435df2e485e405f085982ac8fd9c82fb57d47 05-Jan-2011 Gilles Debunne <debunne@google.com> Revert "Fix for ellipsized text that has two lines at maximum."

This reverts commit 32ea4ffdca0f4706e447d0a275f259fe121b9e6a.

This change introduces an ANR in AutoComplete text view. There is
an infinite loop when the suggestion TextView is measured.

Reverted to fix the ANR, opening a new bug for the ellipsize.

Bug 3315813, 3320375, 3318059

Change-Id: I1872116ca1f39324ed4500d338bafac7e0d195ec
/frameworks/base/core/java/android/text/StaticLayout.java
32ea4ffdca0f4706e447d0a275f259fe121b9e6a 21-Dec-2010 Gilles Debunne <debunne@google.com> Fix for ellipsized text that has two lines at maximum.

The breakOnlyAtSpaces test did not include the reset at the end of the loop
which resets j and w (current position and width). As a result, the second line
was too long from the start and never cut again.

Hours a debug, a simple { change.

Bug 2969667

Change-Id: I1e5b4a37cd9e64d115e6343d7788db3a6ef881e0
/frameworks/base/core/java/android/text/StaticLayout.java
6611147383118cd91cc29b31bff9aaf4c853f39d 19-Nov-2010 Gilles Debunne <debunne@google.com> Clean-up in StaticLayout

Change-Id: I81ac5d8bef7ce8f4f65e3a8c7da8393ce0a87558
/frameworks/base/core/java/android/text/StaticLayout.java
74d31ef2b2c42b54fa1f7cf94ea955ea67ab69a0 06-Aug-2010 Eric Fischer <enf@google.com> Fix a bug where paragraph styles could leak onto an adjacent empty line.

When the text ends with an empty line, the getSpans() call to retrieve
styles for it would also retrieve the styles of the preceding line.
Add a special case to detect and prevent this.

Change-Id: I888131cacce6bf45e68c53c931ebe8d58db0b7a9
/frameworks/base/core/java/android/text/StaticLayout.java
24ca4545f3fa9ffaf0a84af11f1ab74cd14d232e 23-Jun-2010 Kenny Root <kroot@google.com> Check for spanned before computing tab stops

Don't try to check for tab stop spans in non-Spanned text input.

Change-Id: I54d69c8e0246f5a38d0713a89b8b455a478285f0
/frameworks/base/core/java/android/text/StaticLayout.java
c982f60e982c1d2df9f115ed9a5c3ef3643d0892 25-May-2010 Doug Felt <dougfelt@google.com> Fix alignment issues with RTL paragraphs.

Also remove unused debugging code that depends on junit.
Remove trailing whitespace in changed code.

Change-Id: Ie02d1b8220c599a672ee6e91af0fba634e0f620c
/frameworks/base/core/java/android/text/StaticLayout.java
23241887515ed77687c23e29a4a3ffff671666bd 02-Jun-2010 Doug Felt <dougfelt@google.com> Fix IndexOutOfBoundsException when measuring text.

Some line wrapping conditions caused the same style run to be measured
twice, incorrectly advancing the position in the width buffer and
occasionally causing measurement to run out of room. The fix is to
not remeasure the same style run.

Change-Id: Iceb29729c1c27bb602df20fdf83af1da28c82e11
/frameworks/base/core/java/android/text/StaticLayout.java
e8e45f2c05cb3b6d23f30c8f96d8e0b3699cea7a 29-Mar-2010 Doug Felt <dougfelt@google.com> Refactor Styled utility functions into reusable objects.

This takes utility functions from Styled and a few other classes and
incorporates them into two new utility classes, TextLine and
MeasuredText. The main point of this is to support shaping by skia,
to experiment with how this will look, this also introduces
character-based Arabic shaping.

MeasuredText is used by code that determines line breaks by generating
and examining character widths in logical order. Factoring the code
in this way makes it usable by the ellipsize functions in TextUtils as
well as by StaticLayout. This class takes over the caching of widths
and chars arrays that was previously performed by StyledText. A small
number of MeasuredText objects are themselves cached by the class and
accesed using static obtain and recycle methods. Generally only these
few cached instances are ever created.

TextLine is used by code that draws or measures text on a line. This
unifies the line measuring and rendering code, and pushes assumptions
about how rtl text is treated closer to the points where skia code is
invoked. TextLine implements the functions that were previously
provided by Styled, working on member arrays rather than
explicitly-passed arguments. It implements the same kind of static
cache as MeasuredText.

TextLine and MeasureText simulate arabic glyph generation and shaping
by using ArabicShaping, ported with very minor changes from ICU4J's
ArabicShaping. This class generates shaped Arabic glyphs and Lam-Alef
ligatures using Unicode presentation forms. ArabicShaping is not
intended to be permanent, but to be replaced by real shaping from the
skia layer. It is introduced in order to emulate the behavior of real
shaping so that higher level code dealing with rendering shaped text
and cursor movement over ligatures can be developed and tested; it
also provides basic-level support for Arabic.

Since cursor movement depends on conjuncts whose formation is
font-dependent, cursor movement code that was formerly in Layout and
StaticLayout was moved into TextLine so that it can work on the shaped
text.

Other than these changes, the other major change is a rework of the
ellipsize utility functions to combine multiple branches into fewer
branches with additional state.

Updated copyright notices on new files.

Change-Id: I492cb58b51f5aaf6f14cb1419bdbed49eac5ba29
/frameworks/base/core/java/android/text/StaticLayout.java
4e0c5e55e171532760d5f51e0165563827129d4e 16-Mar-2010 Doug Felt <dougfelt@google.com> Don't measure for a secondary caret unless we have one.

Also, clean up imports and trailing whitespace.

Change-Id: I5ebaaceb756600a1ca7370ab3ef078ce200545ef
/frameworks/base/core/java/android/text/StaticLayout.java
9f7a4442b89cc06cb8cae6992484e7ae795323ab 01-Mar-2010 Doug Felt <dougfelt@google.com> Enable nested bidi levels in a paragraph.

Changes the internal representation of direction information in the Directions object to be a visually-ordered list of start/length+direction pairs instead of a list of directionality inversion offsets.

Rewrite Layout.getOffsetToLeft/RightOf to use run information instead of width metrics.

Remove java Bidi, use native. Switch bidi tests to test native, expect levels instead of dirs.

Add test of directionality. Leave in switch to turn new code off and restore previous behavior for now.

Change-Id: Iea8bb46c678a18820e237c90f76007a084c83051
/frameworks/base/core/java/android/text/StaticLayout.java
de61f78340ae23384e16ad675aefdd01ddf07c76 10-Mar-2010 Eric Fischer <enf@google.com> Don't break lines in the middle of a smiley or other graphic replacement.

The code that was supposed to keep this from happening was not being
executed when the text was all ASCII.

Bug 1899722

Change-Id: Ifc97a4423d6136e19abbc4c82eb36ac0216ce415
/frameworks/base/core/java/android/text/StaticLayout.java
20178d62cf669af18467a16d3c4c4237ed42151c 22-Feb-2010 Doug Felt <dougfelt@google.com> Factor bidi algorithm into separate method.

Add rudimentary support for overriding default base line direction heuristic.
Add some simple tests of the bidi implementation.
/frameworks/base/core/java/android/text/StaticLayout.java
1065758a0f8966a8597a61492112f7859a7050a4 22-Feb-2010 Doug Felt <dougfelt@google.com> Fix rounding of extra spacing when it is negative.
/frameworks/base/core/java/android/text/StaticLayout.java
71b8dd71e49016e057c46a257f79162d186a3c3a 17-Feb-2010 Doug Felt <dougfelt@google.com> Enhance text docs, rename some variables for clarity, comment places in the code
for further investigation.
/frameworks/base/core/java/android/text/StaticLayout.java
7b5676e4d40a09ccdbc8b6f691a3d8be23e480d3 16-Oct-2009 Mark Wagner <mxw@google.com> support for multiline paragraph style indentation

This change is likely incomplete and perhaps not right in other ways.
The gist of the change is that the span can return the number of lines
to which to apply the "leading margin".
Some specific things that should be looked at:

1) if the user has nested multiple
LeadingMarginSpans then they will inherit the "line count" feature.
This is wrong but I didn't want to spend time fixing it until it
was clear that this overall approach was acceptible.

2) The units for how many lines should indented is "lines" rather than
something like dips.

3) I wasn't sure what our strategy was for binary compatibility so
I didn't want to modify the methods in LeadingMarginSpan. Instead I
made another interface with extends LeadingMarginSpan that has the
extra method to return the line count.
/frameworks/base/core/java/android/text/StaticLayout.java
a9f1dd021f8f6ee777bc4d27913bd40c42e753af 13-Aug-2009 Eric Fischer <enf@google.com> Make <font size> and <font height> in string resources respect density.

This unfortunately requires API changes because the existing text markup
classes had no access to the screen density.

TextPaint gains a "density" field so that TextView can pass the density
along. AbsoluteSizeSpan gains a new flag to indicate that its argument
is in dip instead of in physical pixels. LineHeightSpan gains an inner
interface whose chooseHeight() method includes a TextPaint argument so
it can get at the density. And when StringBlock creates the markup
objects, it now uses the density-aware versions.

Bug 1976971, Bug 2031746
/frameworks/base/core/java/android/text/StaticLayout.java
549d7243ff9cf638a63a0d5cc82c792b39484e8e 31-Mar-2009 Eric Fischer <> AI 143709: am: CL 143678 am: CL 143540 Try not to start TextView lines with non-starter characters.
TextView was previously following the "relaxed" line breaking
convention and would allow a line break between any two
ideographic characters. Tighten that up and do not allow
line breaks before non-starter characters (sound and iteration
marks and small Hiragana and Katakana).
Original author: enf
Merged from: //branches/cupcake/...
Original author: android-build
Merged from: //branches/donutburger/...

Automated import of CL 143709
/frameworks/base/core/java/android/text/StaticLayout.java
423f0e4205e3c49c6a87b389fa6025772aa7010c 28-Mar-2009 Eric Fischer <> AI 143314: am: CL 143165 am: CL 142861 Make TextView Emoji scale to match the size of the text.
Original author: enf
Merged from: //branches/cupcake/...
Original author: android-build
Merged from: //branches/donutburger/...

Automated import of CL 143314
/frameworks/base/core/java/android/text/StaticLayout.java
105925376f8d0f6b318c9938c7b83ef7fef094da 19-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake_rel/...@140373
/frameworks/base/core/java/android/text/StaticLayout.java
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/text/StaticLayout.java
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/core/java/android/text/StaticLayout.java
d24b8183b93e781080b2c16c487e60d51c12da31 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
/frameworks/base/core/java/android/text/StaticLayout.java
f013e1afd1e68af5e3b868c26a653bbfb39538f8 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
/frameworks/base/core/java/android/text/StaticLayout.java
54b6cfa9a9e5b861a9930af873580d6dc20f773c 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
/frameworks/base/core/java/android/text/StaticLayout.java