Whether ParagraphBuilder requires client ICU or not
Change-Id: Ia9c32fcaff38e82c0ca2e143e5564632edea5a13
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/653416
Auto-Submit: Mouad Debbar <mdebbar@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
Reviewed-by: Julia Lavrova <jlavrova@google.com>
diff --git a/modules/canvaskit/externs.js b/modules/canvaskit/externs.js
index 19b97dd..de9c799 100644
--- a/modules/canvaskit/externs.js
+++ b/modules/canvaskit/externs.js
@@ -167,6 +167,8 @@
Make: function() {},
MakeFromFontProvider: function() {},
ShapeText: function() {},
+ RequiresClientICU() {},
+
addText: function() {},
build: function() {},
diff --git a/modules/canvaskit/npm_build/paragraphs.html b/modules/canvaskit/npm_build/paragraphs.html
index 9188c25..69ae7a6 100644
--- a/modules/canvaskit/npm_build/paragraphs.html
+++ b/modules/canvaskit/npm_build/paragraphs.html
@@ -158,6 +158,8 @@
const mallocedLineBreaks = CanvasKit.Malloc(Uint32Array, lineBreaks.length);
mallocedLineBreaks.toTypedArray().set(lineBreaks);
+ console.log('RequiresClientICU:', CanvasKit.ParagraphBuilder.RequiresClientICU());
+
builder.setWordsUtf16(mallocedWords);
builder.setGraphemeBreaksUtf16(mallocedGraphemes);
builder.setLineBreaksUtf16(mallocedLineBreaks);
diff --git a/modules/canvaskit/npm_build/types/index.d.ts b/modules/canvaskit/npm_build/types/index.d.ts
index e77ff61..13cbd8f 100644
--- a/modules/canvaskit/npm_build/types/index.d.ts
+++ b/modules/canvaskit/npm_build/types/index.d.ts
@@ -3310,6 +3310,12 @@
* Return a shaped array of lines
*/
ShapeText(text: string, runs: FontBlock[], width?: number): ShapedLine[];
+
+ /**
+ * Whether the paragraph builder requires ICU data to be provided by the
+ * client.
+ */
+ RequiresClientICU(): boolean;
}
export interface ParagraphStyleConstructor {
diff --git a/modules/canvaskit/paragraph_bindings.cpp b/modules/canvaskit/paragraph_bindings.cpp
index c7de4bd..68c53b9 100644
--- a/modules/canvaskit/paragraph_bindings.cpp
+++ b/modules/canvaskit/paragraph_bindings.cpp
@@ -553,6 +553,7 @@
return GetShapedLines(*pa);
}),
allow_raw_pointers())
+ .class_function("RequiresClientICU", ¶::ParagraphBuilderImpl::RequiresClientICU)
.function("addText",
optional_override([](para::ParagraphBuilderImpl& self, std::string text) {
return self.addText(text.c_str(), text.length());
diff --git a/modules/skparagraph/src/ParagraphBuilderImpl.cpp b/modules/skparagraph/src/ParagraphBuilderImpl.cpp
index 5c09b63..3b36122 100644
--- a/modules/skparagraph/src/ParagraphBuilderImpl.cpp
+++ b/modules/skparagraph/src/ParagraphBuilderImpl.cpp
@@ -299,5 +299,13 @@
startStyledBlock();
}
+bool ParagraphBuilderImpl::RequiresClientICU() {
+#if !defined(SK_UNICODE_ICU_IMPLEMENTATION) && defined(SK_UNICODE_CLIENT_IMPLEMENTATION)
+ return true;
+#else
+ return false;
+#endif
+}
+
} // namespace textlayout
} // namespace skia
diff --git a/modules/skparagraph/src/ParagraphBuilderImpl.h b/modules/skparagraph/src/ParagraphBuilderImpl.h
index c95bdc6..26f6d94 100644
--- a/modules/skparagraph/src/ParagraphBuilderImpl.h
+++ b/modules/skparagraph/src/ParagraphBuilderImpl.h
@@ -87,6 +87,8 @@
// Just until we fix all the code; calls icu::make inside
static std::unique_ptr<ParagraphBuilder> make(const ParagraphStyle& style,
sk_sp<FontCollection> fontCollection);
+
+ static bool RequiresClientICU();
protected:
void startStyledBlock();
void endRunIfNeeded();