Adapt TextLayoutCache for new Harfbuzz scripts
The Harfbuzz script setting was wired to HB_Script_Common for left-
to-right text and HB_Script_Arabic for right-to-left. This change
selects from additional scripts using some utility APIs from
Harfbuzz.
Change-Id: I34a6f1e0407c8d122bc968443948e7863d1f91ed
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 6e73889..170957c 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -178,6 +178,7 @@
external/icu4c/i18n \
external/icu4c/common \
external/jpeg \
+ external/harfbuzz/contrib \
external/harfbuzz/src \
external/zlib \
frameworks/opt/emoji \
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index 30fe298..a29eb38 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -17,6 +17,10 @@
#include "TextLayoutCache.h"
#include "TextLayout.h"
+extern "C" {
+#include "harfbuzz-unicode.h"
+}
+
namespace android {
TextLayoutCache::TextLayoutCache() :
@@ -355,7 +359,9 @@
shaperItem->item.pos = start;
shaperItem->item.length = count;
shaperItem->item.bidiLevel = isRTL;
- shaperItem->item.script = isRTL ? HB_Script_Arabic : HB_Script_Common;
+
+ ssize_t iter = 0;
+ shaperItem->item.script = code_point_to_script(utf16_to_code_point(chars, count, &iter));
shaperItem->string = chars;
shaperItem->stringLength = contextCount;