diff options
| author | Raph Levien <raph@google.com> | 2014-06-15 17:37:57 -0700 |
|---|---|---|
| committer | Raph Levien <raph@google.com> | 2014-06-19 11:51:54 -0700 |
| commit | e368b6bcfd499543a876b4cae02f1ca563ff1cb6 (patch) | |
| tree | efe90c2a9378523fc5206173f7b73646f014845b | |
| parent | 3f0d6167227d6d2cdd85f7718d92db859b443e92 (diff) | |
| download | frameworks_base-e368b6bcfd499543a876b4cae02f1ca563ff1cb6.zip frameworks_base-e368b6bcfd499543a876b4cae02f1ca563ff1cb6.tar.gz frameworks_base-e368b6bcfd499543a876b4cae02f1ca563ff1cb6.tar.bz2 | |
Use Minikin grapheme cluster breaking
This patch uses the Minikin implementation of grapheme cluster breaking,
which improves the behavior of left and right arrow keys for moving the
cursor. Among other things, it fixes the behavior of jumping over the
"fi" ligature in Roboto.
Part of a fix for b/15653110 Improve behavior of arrow keys in EditText
Change-Id: I80ca54c973d85c49f23b81d51a0fe07a7a853d81
| -rw-r--r-- | core/jni/android/graphics/Paint.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp index d07b154..dc30814 100644 --- a/core/jni/android/graphics/Paint.cpp +++ b/core/jni/android/graphics/Paint.cpp @@ -37,6 +37,7 @@ #include "TextLayout.h" #ifdef USE_MINIKIN +#include <minikin/GraphemeBreak.h> #include <minikin/Layout.h> #include "MinikinSkia.h" #include "MinikinUtils.h" @@ -778,6 +779,11 @@ public: static jint doTextRunCursor(JNIEnv *env, SkPaint* paint, const jchar *text, jint start, jint count, jint flags, jint offset, jint opt) { +#ifdef USE_MINIKIN + GraphemeBreak::MoveOpt moveOpt = GraphemeBreak::MoveOpt(opt); + size_t result = GraphemeBreak::getTextRunCursor(text, start, count, offset, moveOpt); + return static_cast<jint>(result); +#else jfloat scalarArray[count]; TextLayout::getTextRunAdvances(paint, text, start, count, start + count, flags, @@ -818,6 +824,7 @@ public: } return pos; +#endif } static jint getTextRunCursor___C(JNIEnv* env, jobject clazz, jlong paintHandle, jcharArray text, |
