OSDN Git Service

Use getRunAdvance to position cursor
authorRaph Levien <raph@google.com>
Thu, 28 May 2015 23:16:24 +0000 (16:16 -0700)
committerRaph Levien <raph@google.com>
Thu, 28 May 2015 23:36:36 +0000 (16:36 -0700)
commitcb5499c85097450c48f66f6c08a35bab2ad5ab12
treef69fc369640cf4cfb8a006c9034391815c684dee
parentf981ea95f2e951a558f73fb941cf006423e52627
Use getRunAdvance to position cursor

TextLine used to use getTextRunAdvances on a substring to compute a
cursor position, but this had a number of problems, especially when
the substring is a wider than the full string (as can happen in
certain Tamil ligatures).

This patch changes the implementation to use getRunAdvance, which was
explicitly designed for this use case.

We should also change Layout.getHorizontal to use the dual
getOffsetForAdvance, but that's basically a performance optimization,
the functionality should be basically equivalent.

Bug: 21125816
Change-Id: I669b85eaecfbf6f7aa6c6a9dddbf1a210eb94571
core/java/android/text/Layout.java
core/java/android/text/TextLine.java