Reland "Switching SkText to UTF16"
This is a reland of a3262aa1d25eb31f118ee395a0ecae83fd0e27b6
Original change's description:
> Switching SkText to UTF16
>
> Required some changes in SkUnicode to support it
> SkShaper still works on UTF8
>
> Change-Id: I76645668e1d9bf95eb4539a066deea2b24ecf5e9
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/406360
> Reviewed-by: Julia Lavrova <jlavrova@google.com>
> Commit-Queue: Julia Lavrova <jlavrova@google.com>
Change-Id: Ib21898d4acda8ab78e5e6fd1c7b9b0da41c3fa83
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/407396
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
diff --git a/modules/skshaper/src/SkUnicode_icu.cpp b/modules/skshaper/src/SkUnicode_icu.cpp
index 4a3a2e5..93d4fd7 100644
--- a/modules/skshaper/src/SkUnicode_icu.cpp
+++ b/modules/skshaper/src/SkUnicode_icu.cpp
@@ -184,6 +184,23 @@
fLastResult = 0;
return true;
}
+ bool setText(const char16_t utftext16[], int utf16Units) override {
+ UErrorCode status = U_ZERO_ERROR;
+ ICUUText text(utext_openUChars(nullptr, reinterpret_cast<const UChar*>(&utftext16[0]), utf16Units, &status));
+
+ if (U_FAILURE(status)) {
+ SkDEBUGF("Break error: %s", u_errorName(status));
+ return false;
+ }
+ SkASSERT(text);
+ ubrk_setUText(fBreakIterator.get(), text.get(), &status);
+ if (U_FAILURE(status)) {
+ SkDEBUGF("Break error: %s", u_errorName(status));
+ return false;
+ }
+ fLastResult = 0;
+ return true;
+ }
};
class SkIcuBreakIteratorCache {
@@ -427,6 +444,9 @@
}
return std::unique_ptr<SkBreakIterator>(new SkBreakIterator_icu(std::move(iterator)));
}
+ std::unique_ptr<SkBreakIterator> makeBreakIterator(BreakType breakType) override {
+ return makeBreakIterator(uloc_getDefault(), breakType);
+ }
std::unique_ptr<SkScriptIterator> makeScriptIterator() override {
return SkScriptIterator_icu::makeScriptIterator();
}