History log of /frameworks/base/core/java/android/text/StaticLayout.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
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