@shopify/react-native-skia 0.1.222 → 0.1.224
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkApi.h +6 -1
- package/cpp/api/JsiSkFontMgrFactory.h +9 -4
- package/cpp/api/JsiSkParagraph.h +135 -0
- package/cpp/api/JsiSkParagraphBuilder.h +159 -0
- package/cpp/api/JsiSkParagraphStyle.h +124 -0
- package/cpp/api/JsiSkStrutStyle.h +96 -0
- package/cpp/api/JsiSkTextStyle.h +185 -0
- package/cpp/api/{JsiSkTypeFaceFontProviderFactory.h → JsiSkTypefaceFontProviderFactory.h} +1 -1
- package/cpp/jsi/JsiHostObject.h +21 -0
- package/cpp/rnskia/dom/JsiDomApi.h +4 -0
- package/cpp/rnskia/dom/nodes/JsiParagraphNode.h +62 -0
- package/cpp/rnskia/dom/props/ParagraphProp.h +45 -0
- package/cpp/skia/modules/skunicode/include/SkUnicode.h +312 -0
- package/cpp/skia/src/base/SkTInternalLList.h +304 -0
- package/cpp/skia/src/base/SkUTF.h +95 -0
- package/cpp/skia/src/core/SkLRUCache.h +130 -0
- package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +2 -0
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +7 -0
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/ParagraphNode.d.ts +8 -0
- package/lib/commonjs/dom/nodes/drawings/ParagraphNode.js +41 -0
- package/lib/commonjs/dom/nodes/drawings/ParagraphNode.js.map +1 -0
- package/lib/commonjs/dom/types/NodeType.d.ts +2 -1
- package/lib/commonjs/dom/types/NodeType.js +1 -0
- package/lib/commonjs/dom/types/NodeType.js.map +1 -1
- package/lib/commonjs/dom/types/Paragraph.d.ts +8 -0
- package/lib/commonjs/dom/types/Paragraph.js +6 -0
- package/lib/commonjs/dom/types/Paragraph.js.map +1 -0
- package/lib/commonjs/dom/types/SkDOM.d.ts +2 -0
- package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
- package/lib/commonjs/dom/types/index.d.ts +1 -0
- package/lib/commonjs/dom/types/index.js +13 -0
- package/lib/commonjs/dom/types/index.js.map +1 -1
- package/lib/commonjs/renderer/HostComponents.d.ts +3 -1
- package/lib/commonjs/renderer/HostComponents.js +4 -0
- package/lib/commonjs/renderer/HostComponents.js.map +1 -1
- package/lib/commonjs/renderer/components/index.d.ts +1 -0
- package/lib/commonjs/renderer/components/index.js +13 -0
- package/lib/commonjs/renderer/components/index.js.map +1 -1
- package/lib/commonjs/renderer/components/paragraph/Paragraph.d.ts +4 -0
- package/lib/commonjs/renderer/components/paragraph/Paragraph.js +17 -0
- package/lib/commonjs/renderer/components/paragraph/Paragraph.js.map +1 -0
- package/lib/commonjs/renderer/components/paragraph/index.d.ts +1 -0
- package/lib/commonjs/renderer/components/paragraph/index.js +19 -0
- package/lib/commonjs/renderer/components/paragraph/index.js.map +1 -0
- package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +56 -0
- package/lib/commonjs/skia/types/Paragraph/Paragraph.js +6 -0
- package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -0
- package/lib/commonjs/skia/types/Paragraph/ParagraphBuilder.d.ts +60 -0
- package/lib/commonjs/skia/types/Paragraph/ParagraphBuilder.js +18 -0
- package/lib/commonjs/skia/types/Paragraph/ParagraphBuilder.js.map +1 -0
- package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.d.ts +41 -0
- package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.js +36 -0
- package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.js.map +1 -0
- package/lib/commonjs/skia/types/Paragraph/TextStyle.d.ts +62 -0
- package/lib/commonjs/skia/types/Paragraph/TextStyle.js +35 -0
- package/lib/commonjs/skia/types/Paragraph/TextStyle.js.map +1 -0
- package/lib/commonjs/skia/types/Paragraph/index.d.ts +6 -0
- package/lib/commonjs/skia/types/Paragraph/index.js +84 -0
- package/lib/commonjs/skia/types/Paragraph/index.js.map +1 -0
- package/lib/commonjs/skia/types/Skia.d.ts +2 -0
- package/lib/commonjs/skia/types/Skia.js.map +1 -1
- package/lib/commonjs/skia/types/index.d.ts +1 -0
- package/lib/commonjs/skia/types/index.js +13 -0
- package/lib/commonjs/skia/types/index.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkParagraph.d.ts +16 -0
- package/lib/commonjs/skia/web/JsiSkParagraph.js +91 -0
- package/lib/commonjs/skia/web/JsiSkParagraph.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkParagraphBuilder.d.ts +15 -0
- package/lib/commonjs/skia/web/JsiSkParagraphBuilder.js +85 -0
- package/lib/commonjs/skia/web/JsiSkParagraphBuilder.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkParagraphBuilderFactory.d.ts +8 -0
- package/lib/commonjs/skia/web/JsiSkParagraphBuilderFactory.js +34 -0
- package/lib/commonjs/skia/web/JsiSkParagraphBuilderFactory.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.d.ts +5 -0
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +59 -0
- package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkTextStyle.d.ts +5 -0
- package/lib/commonjs/skia/web/JsiSkTextStyle.js +54 -0
- package/lib/commonjs/skia/web/JsiSkTextStyle.js.map +1 -0
- package/lib/commonjs/skia/web/JsiSkia.js +4 -1
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/dom/nodes/JsiSkDOM.d.ts +2 -0
- package/lib/module/dom/nodes/JsiSkDOM.js +6 -0
- package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
- package/lib/module/dom/nodes/drawings/ParagraphNode.d.ts +8 -0
- package/lib/module/dom/nodes/drawings/ParagraphNode.js +30 -0
- package/lib/module/dom/nodes/drawings/ParagraphNode.js.map +1 -0
- package/lib/module/dom/types/NodeType.d.ts +2 -1
- package/lib/module/dom/types/NodeType.js +1 -0
- package/lib/module/dom/types/NodeType.js.map +1 -1
- package/lib/module/dom/types/Paragraph.d.ts +8 -0
- package/lib/module/dom/types/Paragraph.js +2 -0
- package/lib/module/dom/types/Paragraph.js.map +1 -0
- package/lib/module/dom/types/SkDOM.d.ts +2 -0
- package/lib/module/dom/types/SkDOM.js.map +1 -1
- package/lib/module/dom/types/index.d.ts +1 -0
- package/lib/module/dom/types/index.js +1 -0
- package/lib/module/dom/types/index.js.map +1 -1
- package/lib/module/renderer/HostComponents.d.ts +3 -1
- package/lib/module/renderer/HostComponents.js +4 -0
- package/lib/module/renderer/HostComponents.js.map +1 -1
- package/lib/module/renderer/components/index.d.ts +1 -0
- package/lib/module/renderer/components/index.js +1 -0
- package/lib/module/renderer/components/index.js.map +1 -1
- package/lib/module/renderer/components/paragraph/Paragraph.d.ts +4 -0
- package/lib/module/renderer/components/paragraph/Paragraph.js +5 -0
- package/lib/module/renderer/components/paragraph/Paragraph.js.map +1 -0
- package/lib/module/renderer/components/paragraph/index.d.ts +1 -0
- package/lib/module/renderer/components/paragraph/index.js +2 -0
- package/lib/module/renderer/components/paragraph/index.js.map +1 -0
- package/lib/module/skia/types/Paragraph/Paragraph.d.ts +56 -0
- package/lib/module/skia/types/Paragraph/Paragraph.js +2 -0
- package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -0
- package/lib/module/skia/types/Paragraph/ParagraphBuilder.d.ts +60 -0
- package/lib/module/skia/types/Paragraph/ParagraphBuilder.js +11 -0
- package/lib/module/skia/types/Paragraph/ParagraphBuilder.js.map +1 -0
- package/lib/module/skia/types/Paragraph/ParagraphStyle.d.ts +41 -0
- package/lib/module/skia/types/Paragraph/ParagraphStyle.js +27 -0
- package/lib/module/skia/types/Paragraph/ParagraphStyle.js.map +1 -0
- package/lib/module/skia/types/Paragraph/TextStyle.d.ts +62 -0
- package/lib/module/skia/types/Paragraph/TextStyle.js +26 -0
- package/lib/module/skia/types/Paragraph/TextStyle.js.map +1 -0
- package/lib/module/skia/types/Paragraph/index.d.ts +6 -0
- package/lib/module/skia/types/Paragraph/index.js +7 -0
- package/lib/module/skia/types/Paragraph/index.js.map +1 -0
- package/lib/module/skia/types/Skia.d.ts +2 -0
- package/lib/module/skia/types/Skia.js.map +1 -1
- package/lib/module/skia/types/index.d.ts +1 -0
- package/lib/module/skia/types/index.js +1 -0
- package/lib/module/skia/types/index.js.map +1 -1
- package/lib/module/skia/web/JsiSkParagraph.d.ts +16 -0
- package/lib/module/skia/web/JsiSkParagraph.js +81 -0
- package/lib/module/skia/web/JsiSkParagraph.js.map +1 -0
- package/lib/module/skia/web/JsiSkParagraphBuilder.d.ts +15 -0
- package/lib/module/skia/web/JsiSkParagraphBuilder.js +73 -0
- package/lib/module/skia/web/JsiSkParagraphBuilder.js.map +1 -0
- package/lib/module/skia/web/JsiSkParagraphBuilderFactory.d.ts +8 -0
- package/lib/module/skia/web/JsiSkParagraphBuilderFactory.js +21 -0
- package/lib/module/skia/web/JsiSkParagraphBuilderFactory.js.map +1 -0
- package/lib/module/skia/web/JsiSkParagraphStyle.d.ts +5 -0
- package/lib/module/skia/web/JsiSkParagraphStyle.js +49 -0
- package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -0
- package/lib/module/skia/web/JsiSkTextStyle.d.ts +5 -0
- package/lib/module/skia/web/JsiSkTextStyle.js +45 -0
- package/lib/module/skia/web/JsiSkTextStyle.js.map +1 -0
- package/lib/module/skia/web/JsiSkia.js +3 -1
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -0
- package/lib/typescript/src/dom/nodes/drawings/ParagraphNode.d.ts +8 -0
- package/lib/typescript/src/dom/types/NodeType.d.ts +2 -1
- package/lib/typescript/src/dom/types/Paragraph.d.ts +8 -0
- package/lib/typescript/src/dom/types/SkDOM.d.ts +2 -0
- package/lib/typescript/src/dom/types/index.d.ts +1 -0
- package/lib/typescript/src/renderer/HostComponents.d.ts +3 -1
- package/lib/typescript/src/renderer/components/index.d.ts +1 -0
- package/lib/typescript/src/renderer/components/paragraph/Paragraph.d.ts +4 -0
- package/lib/typescript/src/renderer/components/paragraph/index.d.ts +1 -0
- package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +56 -0
- package/lib/typescript/src/skia/types/Paragraph/ParagraphBuilder.d.ts +60 -0
- package/lib/typescript/src/skia/types/Paragraph/ParagraphStyle.d.ts +41 -0
- package/lib/typescript/src/skia/types/Paragraph/TextStyle.d.ts +62 -0
- package/lib/typescript/src/skia/types/Paragraph/index.d.ts +6 -0
- package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
- package/lib/typescript/src/skia/types/index.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkParagraph.d.ts +16 -0
- package/lib/typescript/src/skia/web/JsiSkParagraphBuilder.d.ts +15 -0
- package/lib/typescript/src/skia/web/JsiSkParagraphBuilderFactory.d.ts +8 -0
- package/lib/typescript/src/skia/web/JsiSkParagraphStyle.d.ts +5 -0
- package/lib/typescript/src/skia/web/JsiSkTextStyle.d.ts +5 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
- package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
- package/libs/ios/libskottie.xcframework/Info.plist +5 -5
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
- package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
- package/libs/ios/libskparagraph.xcframework/Info.plist +5 -5
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
- package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
- package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
- package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
- package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
- package/libs/ios/libsvg.xcframework/Info.plist +5 -5
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
- package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
- package/package.json +1 -1
- package/src/dom/nodes/JsiSkDOM.ts +9 -0
- package/src/dom/nodes/drawings/ParagraphNode.ts +22 -0
- package/src/dom/types/NodeType.ts +3 -0
- package/src/dom/types/Paragraph.ts +10 -0
- package/src/dom/types/SkDOM.ts +4 -0
- package/src/dom/types/index.ts +1 -0
- package/src/renderer/HostComponents.ts +10 -0
- package/src/renderer/components/index.ts +2 -0
- package/src/renderer/components/paragraph/Paragraph.tsx +8 -0
- package/src/renderer/components/paragraph/index.ts +1 -0
- package/src/skia/types/Paragraph/Paragraph.ts +59 -0
- package/src/skia/types/Paragraph/ParagraphBuilder.ts +96 -0
- package/src/skia/types/Paragraph/ParagraphStyle.ts +45 -0
- package/src/skia/types/Paragraph/TextStyle.ts +70 -0
- package/src/skia/types/Paragraph/index.ts +6 -0
- package/src/skia/types/Skia.ts +3 -0
- package/src/skia/types/index.ts +1 -0
- package/src/skia/web/JsiSkParagraph.ts +69 -0
- package/src/skia/web/JsiSkParagraphBuilder.ts +99 -0
- package/src/skia/web/JsiSkParagraphBuilderFactory.ts +42 -0
- package/src/skia/web/JsiSkParagraphStyle.ts +65 -0
- package/src/skia/web/JsiSkTextStyle.ts +53 -0
- package/src/skia/web/JsiSkia.ts +2 -0
- /package/cpp/api/{JsiSkTypeFaceFontProvider.h → JsiSkTypefaceFontProvider.h} +0 -0
@@ -0,0 +1,185 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include <memory>
|
4
|
+
#include <string>
|
5
|
+
#include <utility>
|
6
|
+
#include <vector>
|
7
|
+
|
8
|
+
#include <jsi/jsi.h>
|
9
|
+
|
10
|
+
#pragma clang diagnostic push
|
11
|
+
#pragma clang diagnostic ignored "-Wdocumentation"
|
12
|
+
|
13
|
+
#include "Paragraph.h"
|
14
|
+
#include "ParagraphStyle.h"
|
15
|
+
|
16
|
+
#pragma clang diagnostic pop
|
17
|
+
|
18
|
+
namespace RNSkia {
|
19
|
+
|
20
|
+
namespace jsi = facebook::jsi;
|
21
|
+
|
22
|
+
namespace para = skia::textlayout;
|
23
|
+
|
24
|
+
/**
|
25
|
+
Implementation of the TextStyle object in JSI for the paragraph builder
|
26
|
+
*/
|
27
|
+
class JsiSkTextStyle {
|
28
|
+
public:
|
29
|
+
static para::TextStyle fromValue(jsi::Runtime &runtime,
|
30
|
+
const jsi::Value &value) {
|
31
|
+
|
32
|
+
para::TextStyle retVal;
|
33
|
+
|
34
|
+
// Accept undefined && null
|
35
|
+
if (value.isUndefined() || value.isNull()) {
|
36
|
+
return retVal;
|
37
|
+
}
|
38
|
+
|
39
|
+
// Read values from the argument - expected to be a TextStyle shaped object
|
40
|
+
if (!value.isObject()) {
|
41
|
+
throw jsi::JSError(runtime, "Expected SkTextStyle as first argument");
|
42
|
+
}
|
43
|
+
|
44
|
+
auto object = value.asObject(runtime);
|
45
|
+
|
46
|
+
if (object.hasProperty(runtime, "backgroundColor")) {
|
47
|
+
auto propValue = object.getProperty(runtime, "backgroundColor");
|
48
|
+
SkPaint p;
|
49
|
+
p.setColor(JsiSkColor::fromValue(runtime, propValue));
|
50
|
+
retVal.setBackgroundPaint(p);
|
51
|
+
}
|
52
|
+
if (object.hasProperty(runtime, "color")) {
|
53
|
+
auto propValue = object.getProperty(runtime, "color");
|
54
|
+
retVal.setColor(JsiSkColor::fromValue(runtime, propValue));
|
55
|
+
}
|
56
|
+
if (object.hasProperty(runtime, "decoration")) {
|
57
|
+
auto propValue = object.getProperty(runtime, "decoration");
|
58
|
+
retVal.setDecoration(
|
59
|
+
static_cast<para::TextDecoration>(propValue.asNumber()));
|
60
|
+
}
|
61
|
+
if (object.hasProperty(runtime, "decorationColor")) {
|
62
|
+
auto propValue = object.getProperty(runtime, "decorationColor");
|
63
|
+
retVal.setDecorationColor(JsiSkColor::fromValue(runtime, propValue));
|
64
|
+
}
|
65
|
+
if (object.hasProperty(runtime, "decorationThickness")) {
|
66
|
+
auto propValue = object.getProperty(runtime, "decorationThickness");
|
67
|
+
retVal.setDecorationThicknessMultiplier(propValue.asNumber());
|
68
|
+
}
|
69
|
+
if (object.hasProperty(runtime, "decorationStyle")) {
|
70
|
+
auto propValue = object.getProperty(runtime, "decorationStyle");
|
71
|
+
retVal.setDecorationStyle(
|
72
|
+
static_cast<para::TextDecorationStyle>(propValue.asNumber()));
|
73
|
+
}
|
74
|
+
if (object.hasProperty(runtime, "fontFamilies")) {
|
75
|
+
auto propValue = object.getProperty(runtime, "fontFamilies")
|
76
|
+
.asObject(runtime)
|
77
|
+
.asArray(runtime);
|
78
|
+
auto size = propValue.size(runtime);
|
79
|
+
std::vector<SkString> families(size);
|
80
|
+
for (size_t i = 0; i < size; ++i) {
|
81
|
+
families[i] = propValue.getValueAtIndex(runtime, i)
|
82
|
+
.asString(runtime)
|
83
|
+
.utf8(runtime)
|
84
|
+
.c_str();
|
85
|
+
}
|
86
|
+
retVal.setFontFamilies(families);
|
87
|
+
}
|
88
|
+
if (object.hasProperty(runtime, "fontFeatures")) {
|
89
|
+
auto propValue = object.getProperty(runtime, "fontFeatures")
|
90
|
+
.asObject(runtime)
|
91
|
+
.asArray(runtime);
|
92
|
+
auto size = propValue.size(runtime);
|
93
|
+
retVal.resetFontFeatures();
|
94
|
+
for (size_t i = 0; i < size; ++i) {
|
95
|
+
auto element = propValue.getValueAtIndex(runtime, i).asObject(runtime);
|
96
|
+
auto name = element.getProperty(runtime, "name")
|
97
|
+
.asString(runtime)
|
98
|
+
.utf8(runtime);
|
99
|
+
auto value = element.getProperty(runtime, "value").asNumber();
|
100
|
+
retVal.addFontFeature(SkString(name), value);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
if (object.hasProperty(runtime, "fontSize")) {
|
104
|
+
auto propValue = object.getProperty(runtime, "fontSize");
|
105
|
+
retVal.setFontSize(propValue.asNumber());
|
106
|
+
}
|
107
|
+
if (object.hasProperty(runtime, "fontStyle")) {
|
108
|
+
auto propValue =
|
109
|
+
object.getProperty(runtime, "fontStyle").asObject(runtime);
|
110
|
+
auto weight = static_cast<SkFontStyle::Weight>(
|
111
|
+
propValue.hasProperty(runtime, "weight")
|
112
|
+
? propValue.getProperty(runtime, "weight").asNumber()
|
113
|
+
: SkFontStyle::Weight::kNormal_Weight);
|
114
|
+
|
115
|
+
auto width = static_cast<SkFontStyle::Width>(
|
116
|
+
propValue.hasProperty(runtime, "width")
|
117
|
+
? propValue.getProperty(runtime, "width").asNumber()
|
118
|
+
: SkFontStyle::Width::kNormal_Width);
|
119
|
+
|
120
|
+
auto slant = static_cast<SkFontStyle::Slant>(
|
121
|
+
propValue.hasProperty(runtime, "slant")
|
122
|
+
? propValue.getProperty(runtime, "slant").asNumber()
|
123
|
+
: SkFontStyle::Slant::kUpright_Slant);
|
124
|
+
|
125
|
+
retVal.setFontStyle(SkFontStyle(weight, width, slant));
|
126
|
+
}
|
127
|
+
if (object.hasProperty(runtime, "foregroundColor")) {
|
128
|
+
auto propValue = object.getProperty(runtime, "foregroundColor");
|
129
|
+
SkPaint p;
|
130
|
+
p.setColor(JsiSkColor::fromValue(runtime, propValue));
|
131
|
+
retVal.setForegroundColor(p);
|
132
|
+
}
|
133
|
+
if (object.hasProperty(runtime, "heightMultiplier")) {
|
134
|
+
auto propValue = object.getProperty(runtime, "heightMultiplier");
|
135
|
+
retVal.setHeight(propValue.asNumber());
|
136
|
+
retVal.setHeightOverride(true);
|
137
|
+
}
|
138
|
+
if (object.hasProperty(runtime, "halfLeading")) {
|
139
|
+
auto propValue = object.getProperty(runtime, "halfLeading");
|
140
|
+
retVal.setHalfLeading(propValue.asNumber());
|
141
|
+
}
|
142
|
+
if (object.hasProperty(runtime, "letterSpacing")) {
|
143
|
+
auto propValue = object.getProperty(runtime, "letterSpacing");
|
144
|
+
retVal.setLetterSpacing(propValue.asNumber());
|
145
|
+
}
|
146
|
+
if (object.hasProperty(runtime, "locale")) {
|
147
|
+
auto propValue = object.getProperty(runtime, "locale");
|
148
|
+
retVal.setLocale(SkString(propValue.asString(runtime).utf8(runtime)));
|
149
|
+
}
|
150
|
+
if (object.hasProperty(runtime, "shadows")) {
|
151
|
+
auto propValue = object.getProperty(runtime, "shadows")
|
152
|
+
.asObject(runtime)
|
153
|
+
.asArray(runtime);
|
154
|
+
auto size = propValue.size(runtime);
|
155
|
+
retVal.resetShadows();
|
156
|
+
for (size_t i = 0; i < size; ++i) {
|
157
|
+
auto element = propValue.getValueAtIndex(runtime, i).asObject(runtime);
|
158
|
+
auto color = element.hasProperty(runtime, "color")
|
159
|
+
? JsiSkColor::fromValue(
|
160
|
+
runtime, element.getProperty(runtime, "color"))
|
161
|
+
: SK_ColorBLACK;
|
162
|
+
SkPoint offset =
|
163
|
+
element.hasProperty(runtime, "offset")
|
164
|
+
? *JsiSkPoint::fromValue(runtime,
|
165
|
+
element.getProperty(runtime, "offset"))
|
166
|
+
.get()
|
167
|
+
: SkPoint::Make(0, 0);
|
168
|
+
auto blurSigma =
|
169
|
+
element.hasProperty(runtime, "blurRadius")
|
170
|
+
? element.getProperty(runtime, "blurRadius").asNumber()
|
171
|
+
: 0;
|
172
|
+
retVal.addShadow(para::TextShadow(color, offset, blurSigma));
|
173
|
+
}
|
174
|
+
}
|
175
|
+
if (object.hasProperty(runtime, "textBaseline")) {
|
176
|
+
auto propValue = object.getProperty(runtime, "textBaseline");
|
177
|
+
retVal.setTextBaseline(
|
178
|
+
static_cast<para::TextBaseline>(propValue.asNumber()));
|
179
|
+
}
|
180
|
+
|
181
|
+
return retVal;
|
182
|
+
}
|
183
|
+
};
|
184
|
+
|
185
|
+
} // namespace RNSkia
|
package/cpp/jsi/JsiHostObject.h
CHANGED
@@ -331,6 +331,27 @@ protected:
|
|
331
331
|
return value.asHostObject<T>(runtime);
|
332
332
|
}
|
333
333
|
|
334
|
+
/**
|
335
|
+
Returns argument as host object or nullptr if the value is not a valid host
|
336
|
+
object of requested type
|
337
|
+
*/
|
338
|
+
template <typename T = HostObject>
|
339
|
+
static std::shared_ptr<T>
|
340
|
+
tryGetArgumentAsHostObject(jsi::Runtime &runtime, const jsi::Value *arguments,
|
341
|
+
size_t count, size_t index) {
|
342
|
+
const jsi::Value &value = getArgument(runtime, arguments, count, index);
|
343
|
+
if (!value.isObject()) {
|
344
|
+
return nullptr;
|
345
|
+
}
|
346
|
+
|
347
|
+
auto object = value.asObject(runtime);
|
348
|
+
if (!object.isHostObject(runtime)) {
|
349
|
+
return nullptr;
|
350
|
+
}
|
351
|
+
|
352
|
+
return object.asHostObject<T>(runtime);
|
353
|
+
}
|
354
|
+
|
334
355
|
/**
|
335
356
|
Returns argument as array or throws
|
336
357
|
*/
|
@@ -48,6 +48,7 @@
|
|
48
48
|
#include "nodes/JsiTextPathNode.h"
|
49
49
|
|
50
50
|
#include "nodes/JsiLayerNode.h"
|
51
|
+
#include "nodes/JsiParagraphNode.h"
|
51
52
|
|
52
53
|
namespace RNSkia {
|
53
54
|
|
@@ -162,6 +163,9 @@ public:
|
|
162
163
|
installFunction("TextBlobNode", JsiTextBlobNode::createCtor(context));
|
163
164
|
|
164
165
|
installFunction("LayerNode", JsiLayerNode::createCtor(context));
|
166
|
+
|
167
|
+
// Paragraph node
|
168
|
+
installFunction("ParagraphNode", JsiParagraphNode::createCtor(context));
|
165
169
|
}
|
166
170
|
};
|
167
171
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "JsiDomDrawingNode.h"
|
4
|
+
#include "ParagraphProp.h"
|
5
|
+
|
6
|
+
#include <memory>
|
7
|
+
|
8
|
+
namespace RNSkia {
|
9
|
+
|
10
|
+
class JsiParagraphNode : public JsiDomDrawingNode,
|
11
|
+
public JsiDomNodeCtor<JsiParagraphNode> {
|
12
|
+
public:
|
13
|
+
explicit JsiParagraphNode(std::shared_ptr<RNSkPlatformContext> context)
|
14
|
+
: JsiDomDrawingNode(context, "skParagraph") {}
|
15
|
+
|
16
|
+
protected:
|
17
|
+
void draw(DrawingContext *context) override {
|
18
|
+
auto x = _xProp->value().getAsNumber();
|
19
|
+
auto y = _yProp->value().getAsNumber();
|
20
|
+
auto width = static_cast<SkScalar>(_widthProp->value().getAsNumber());
|
21
|
+
|
22
|
+
auto p = *_paragraphProp->getDerivedValue();
|
23
|
+
if (p != nullptr) {
|
24
|
+
|
25
|
+
// Let's ensure that we don't perform unnecessary layouts on the
|
26
|
+
// paragraph. We should only layout if we have a new paragraph or if the
|
27
|
+
// layout width has changed.
|
28
|
+
if (_lastLayoutWidth != width || _lastLayoutParagraph != p) {
|
29
|
+
// perform layout!
|
30
|
+
p->layout(width);
|
31
|
+
_lastLayoutWidth = width;
|
32
|
+
_lastLayoutParagraph = p;
|
33
|
+
}
|
34
|
+
// Paint the layout to the canvas
|
35
|
+
p->paint(context->getCanvas(), x, y);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
void defineProperties(NodePropsContainer *container) override {
|
40
|
+
JsiDomDrawingNode::defineProperties(container);
|
41
|
+
_paragraphProp = container->defineProperty<ParagraphProp>("paragraph");
|
42
|
+
|
43
|
+
_xProp = container->defineProperty<NodeProp>("x");
|
44
|
+
_xProp->require();
|
45
|
+
|
46
|
+
_yProp = container->defineProperty<NodeProp>("y");
|
47
|
+
_yProp->require();
|
48
|
+
|
49
|
+
_widthProp = container->defineProperty<NodeProp>("width");
|
50
|
+
_widthProp->require();
|
51
|
+
}
|
52
|
+
|
53
|
+
private:
|
54
|
+
ParagraphProp *_paragraphProp;
|
55
|
+
NodeProp *_xProp;
|
56
|
+
NodeProp *_yProp;
|
57
|
+
NodeProp *_widthProp;
|
58
|
+
SkScalar _lastLayoutWidth;
|
59
|
+
para::Paragraph *_lastLayoutParagraph = nullptr;
|
60
|
+
};
|
61
|
+
|
62
|
+
} // namespace RNSkia
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "DerivedNodeProp.h"
|
4
|
+
|
5
|
+
#include "JsiSkParagraph.h"
|
6
|
+
|
7
|
+
#include <memory>
|
8
|
+
#include <string>
|
9
|
+
|
10
|
+
namespace RNSkia {
|
11
|
+
|
12
|
+
class ParagraphProp : public DerivedProp<para::Paragraph *> {
|
13
|
+
public:
|
14
|
+
explicit ParagraphProp(PropId name,
|
15
|
+
const std::function<void(BaseNodeProp *)> &onChange)
|
16
|
+
: DerivedProp<para::Paragraph *>(onChange) {
|
17
|
+
_paragraphProp = defineProperty<NodeProp>(name);
|
18
|
+
}
|
19
|
+
|
20
|
+
void updateDerivedValue() override {
|
21
|
+
if (_paragraphProp->isSet()) {
|
22
|
+
if (_paragraphProp->value().getType() != PropType::HostObject) {
|
23
|
+
throw std::runtime_error("Expected Paragraph object for the " +
|
24
|
+
std::string(getName()) + " property.");
|
25
|
+
}
|
26
|
+
|
27
|
+
auto ptr = std::dynamic_pointer_cast<JsiSkParagraph>(
|
28
|
+
_paragraphProp->value().getAsHostObject());
|
29
|
+
|
30
|
+
if (ptr == nullptr) {
|
31
|
+
throw std::runtime_error("Expected paragraph object for the " +
|
32
|
+
std::string(getName()) + " property.");
|
33
|
+
}
|
34
|
+
|
35
|
+
setDerivedValue(ptr->getParagraph());
|
36
|
+
} else {
|
37
|
+
setDerivedValue(nullptr);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
private:
|
42
|
+
NodeProp *_paragraphProp;
|
43
|
+
};
|
44
|
+
|
45
|
+
} // namespace RNSkia
|
@@ -0,0 +1,312 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright 2020 Google LLC
|
3
|
+
*
|
4
|
+
* Use of this source code is governed by a BSD-style license that can be
|
5
|
+
* found in the LICENSE file.
|
6
|
+
*/
|
7
|
+
#ifndef SkUnicode_DEFINED
|
8
|
+
#define SkUnicode_DEFINED
|
9
|
+
#include "include/core/SkSpan.h"
|
10
|
+
#include "include/core/SkString.h"
|
11
|
+
#include "include/core/SkTypes.h"
|
12
|
+
#include "include/private/base/SkTArray.h"
|
13
|
+
#include "include/private/base/SkTo.h"
|
14
|
+
#include "src/base/SkUTF.h"
|
15
|
+
|
16
|
+
#include <cstddef>
|
17
|
+
#include <cstdint>
|
18
|
+
#include <memory>
|
19
|
+
#include <string>
|
20
|
+
#include <vector>
|
21
|
+
|
22
|
+
#if !defined(SKUNICODE_IMPLEMENTATION)
|
23
|
+
#define SKUNICODE_IMPLEMENTATION 0
|
24
|
+
#endif
|
25
|
+
|
26
|
+
#if !defined(SKUNICODE_API)
|
27
|
+
#if defined(SKUNICODE_DLL)
|
28
|
+
#if defined(_MSC_VER)
|
29
|
+
#if SKUNICODE_IMPLEMENTATION
|
30
|
+
#define SKUNICODE_API __declspec(dllexport)
|
31
|
+
#else
|
32
|
+
#define SKUNICODE_API __declspec(dllimport)
|
33
|
+
#endif
|
34
|
+
#else
|
35
|
+
#define SKUNICODE_API __attribute__((visibility("default")))
|
36
|
+
#endif
|
37
|
+
#else
|
38
|
+
#define SKUNICODE_API
|
39
|
+
#endif
|
40
|
+
#endif
|
41
|
+
|
42
|
+
namespace sknonstd {
|
43
|
+
template <typename T> struct is_bitmask_enum;
|
44
|
+
}
|
45
|
+
|
46
|
+
class SKUNICODE_API SkBidiIterator {
|
47
|
+
public:
|
48
|
+
typedef int32_t Position;
|
49
|
+
typedef uint8_t Level;
|
50
|
+
struct Region {
|
51
|
+
Region(Position start, Position end, Level level)
|
52
|
+
: start(start), end(end), level(level) { }
|
53
|
+
Position start;
|
54
|
+
Position end;
|
55
|
+
Level level;
|
56
|
+
};
|
57
|
+
enum Direction {
|
58
|
+
kLTR,
|
59
|
+
kRTL,
|
60
|
+
};
|
61
|
+
virtual ~SkBidiIterator() = default;
|
62
|
+
virtual Position getLength() = 0;
|
63
|
+
virtual Level getLevelAt(Position) = 0;
|
64
|
+
};
|
65
|
+
|
66
|
+
class SKUNICODE_API SkBreakIterator {
|
67
|
+
public:
|
68
|
+
typedef int32_t Position;
|
69
|
+
typedef int32_t Status;
|
70
|
+
virtual ~SkBreakIterator() = default;
|
71
|
+
virtual Position first() = 0;
|
72
|
+
virtual Position current() = 0;
|
73
|
+
virtual Position next() = 0;
|
74
|
+
virtual Status status() = 0;
|
75
|
+
virtual bool isDone() = 0;
|
76
|
+
virtual bool setText(const char utftext8[], int utf8Units) = 0;
|
77
|
+
virtual bool setText(const char16_t utftext16[], int utf16Units) = 0;
|
78
|
+
};
|
79
|
+
|
80
|
+
class SKUNICODE_API SkUnicode {
|
81
|
+
public:
|
82
|
+
enum CodeUnitFlags {
|
83
|
+
kNoCodeUnitFlag = 0x00,
|
84
|
+
kPartOfWhiteSpaceBreak = 0x01,
|
85
|
+
kGraphemeStart = 0x02,
|
86
|
+
kSoftLineBreakBefore = 0x04,
|
87
|
+
kHardLineBreakBefore = 0x08,
|
88
|
+
kPartOfIntraWordBreak = 0x10,
|
89
|
+
kControl = 0x20,
|
90
|
+
kTabulation = 0x40,
|
91
|
+
kGlyphClusterStart = 0x80,
|
92
|
+
kIdeographic = 0x100,
|
93
|
+
kEmoji = 0x200,
|
94
|
+
kWordBreak = 0x400,
|
95
|
+
kSentenceBreak = 0x800,
|
96
|
+
};
|
97
|
+
enum class TextDirection {
|
98
|
+
kLTR,
|
99
|
+
kRTL,
|
100
|
+
};
|
101
|
+
typedef size_t Position;
|
102
|
+
typedef uint8_t BidiLevel;
|
103
|
+
struct BidiRegion {
|
104
|
+
BidiRegion(Position start, Position end, BidiLevel level)
|
105
|
+
: start(start), end(end), level(level) { }
|
106
|
+
Position start;
|
107
|
+
Position end;
|
108
|
+
BidiLevel level;
|
109
|
+
};
|
110
|
+
enum class LineBreakType {
|
111
|
+
kSoftLineBreak = 0,
|
112
|
+
kHardLineBreak = 100,
|
113
|
+
};
|
114
|
+
|
115
|
+
enum class BreakType { kWords, kGraphemes, kLines, kSentences };
|
116
|
+
struct LineBreakBefore {
|
117
|
+
LineBreakBefore(Position pos, LineBreakType breakType)
|
118
|
+
: pos(pos), breakType(breakType) { }
|
119
|
+
Position pos;
|
120
|
+
LineBreakType breakType;
|
121
|
+
};
|
122
|
+
|
123
|
+
virtual ~SkUnicode() = default;
|
124
|
+
|
125
|
+
virtual SkString toUpper(const SkString&) = 0;
|
126
|
+
|
127
|
+
virtual bool isControl(SkUnichar utf8) = 0;
|
128
|
+
virtual bool isWhitespace(SkUnichar utf8) = 0;
|
129
|
+
virtual bool isSpace(SkUnichar utf8) = 0;
|
130
|
+
virtual bool isTabulation(SkUnichar utf8) = 0;
|
131
|
+
virtual bool isHardBreak(SkUnichar utf8) = 0;
|
132
|
+
virtual bool isEmoji(SkUnichar utf8) = 0;
|
133
|
+
virtual bool isIdeographic(SkUnichar utf8) = 0;
|
134
|
+
|
135
|
+
// Methods used in SkShaper and SkText
|
136
|
+
virtual std::unique_ptr<SkBidiIterator> makeBidiIterator
|
137
|
+
(const uint16_t text[], int count, SkBidiIterator::Direction) = 0;
|
138
|
+
virtual std::unique_ptr<SkBidiIterator> makeBidiIterator
|
139
|
+
(const char text[], int count, SkBidiIterator::Direction) = 0;
|
140
|
+
virtual std::unique_ptr<SkBreakIterator> makeBreakIterator
|
141
|
+
(const char locale[], BreakType breakType) = 0;
|
142
|
+
virtual std::unique_ptr<SkBreakIterator> makeBreakIterator(BreakType type) = 0;
|
143
|
+
|
144
|
+
// Methods used in SkParagraph
|
145
|
+
static bool hasTabulationFlag(SkUnicode::CodeUnitFlags flags);
|
146
|
+
static bool hasHardLineBreakFlag(SkUnicode::CodeUnitFlags flags);
|
147
|
+
static bool hasSoftLineBreakFlag(SkUnicode::CodeUnitFlags flags);
|
148
|
+
static bool hasGraphemeStartFlag(SkUnicode::CodeUnitFlags flags);
|
149
|
+
static bool hasControlFlag(SkUnicode::CodeUnitFlags flags);
|
150
|
+
static bool hasPartOfWhiteSpaceBreakFlag(SkUnicode::CodeUnitFlags flags);
|
151
|
+
|
152
|
+
static bool extractBidi(const char utf8[],
|
153
|
+
int utf8Units,
|
154
|
+
TextDirection dir,
|
155
|
+
std::vector<BidiRegion>* bidiRegions);
|
156
|
+
virtual bool getBidiRegions(const char utf8[],
|
157
|
+
int utf8Units,
|
158
|
+
TextDirection dir,
|
159
|
+
std::vector<BidiRegion>* results) = 0;
|
160
|
+
// Returns results in utf16
|
161
|
+
virtual bool getWords(const char utf8[], int utf8Units, const char* locale,
|
162
|
+
std::vector<Position>* results) = 0;
|
163
|
+
virtual bool getUtf8Words(const char utf8[],
|
164
|
+
int utf8Units,
|
165
|
+
const char* locale,
|
166
|
+
std::vector<Position>* results) = 0;
|
167
|
+
virtual bool getSentences(const char utf8[],
|
168
|
+
int utf8Units,
|
169
|
+
const char* locale,
|
170
|
+
std::vector<Position>* results) = 0;
|
171
|
+
virtual bool computeCodeUnitFlags(
|
172
|
+
char utf8[], int utf8Units, bool replaceTabs,
|
173
|
+
skia_private::TArray<SkUnicode::CodeUnitFlags, true>* results) = 0;
|
174
|
+
virtual bool computeCodeUnitFlags(
|
175
|
+
char16_t utf16[], int utf16Units, bool replaceTabs,
|
176
|
+
skia_private::TArray<SkUnicode::CodeUnitFlags, true>* results) = 0;
|
177
|
+
|
178
|
+
static SkString convertUtf16ToUtf8(const char16_t * utf16, int utf16Units);
|
179
|
+
static SkString convertUtf16ToUtf8(const std::u16string& utf16);
|
180
|
+
static std::u16string convertUtf8ToUtf16(const char* utf8, int utf8Units);
|
181
|
+
static std::u16string convertUtf8ToUtf16(const SkString& utf8);
|
182
|
+
|
183
|
+
template <typename Appender8, typename Appender16>
|
184
|
+
static bool extractUtfConversionMapping(SkSpan<const char> utf8, Appender8&& appender8, Appender16&& appender16) {
|
185
|
+
size_t size8 = 0;
|
186
|
+
size_t size16 = 0;
|
187
|
+
auto ptr = utf8.begin();
|
188
|
+
auto end = utf8.end();
|
189
|
+
while (ptr < end) {
|
190
|
+
|
191
|
+
size_t index = SkToSizeT(ptr - utf8.begin());
|
192
|
+
SkUnichar u = SkUTF::NextUTF8(&ptr, end);
|
193
|
+
|
194
|
+
// All UTF8 code units refer to the same codepoint
|
195
|
+
size_t next = SkToSizeT(ptr - utf8.begin());
|
196
|
+
for (auto i = index; i < next; ++i) {
|
197
|
+
//fUTF16IndexForUTF8Index.emplace_back(fUTF8IndexForUTF16Index.size());
|
198
|
+
appender16(size8);
|
199
|
+
++size16;
|
200
|
+
}
|
201
|
+
//SkASSERT(fUTF16IndexForUTF8Index.size() == next);
|
202
|
+
SkASSERT(size16 == next);
|
203
|
+
if (size16 != next) {
|
204
|
+
return false;
|
205
|
+
}
|
206
|
+
|
207
|
+
// One or two UTF16 code units refer to the same codepoint
|
208
|
+
uint16_t buffer[2];
|
209
|
+
size_t count = SkUTF::ToUTF16(u, buffer);
|
210
|
+
//fUTF8IndexForUTF16Index.emplace_back(index);
|
211
|
+
appender8(index);
|
212
|
+
++size8;
|
213
|
+
if (count > 1) {
|
214
|
+
//fUTF8IndexForUTF16Index.emplace_back(index);
|
215
|
+
appender8(index);
|
216
|
+
++size8;
|
217
|
+
}
|
218
|
+
}
|
219
|
+
//fUTF16IndexForUTF8Index.emplace_back(fUTF8IndexForUTF16Index.size());
|
220
|
+
appender16(size8);
|
221
|
+
++size16;
|
222
|
+
//fUTF8IndexForUTF16Index.emplace_back(fText.size());
|
223
|
+
appender8(utf8.size());
|
224
|
+
++size8;
|
225
|
+
|
226
|
+
return true;
|
227
|
+
}
|
228
|
+
|
229
|
+
template <typename Callback>
|
230
|
+
void forEachCodepoint(const char* utf8, int32_t utf8Units, Callback&& callback) {
|
231
|
+
const char* current = utf8;
|
232
|
+
const char* end = utf8 + utf8Units;
|
233
|
+
while (current < end) {
|
234
|
+
auto before = current - utf8;
|
235
|
+
SkUnichar unichar = SkUTF::NextUTF8(¤t, end);
|
236
|
+
if (unichar < 0) unichar = 0xFFFD;
|
237
|
+
auto after = current - utf8;
|
238
|
+
uint16_t buffer[2];
|
239
|
+
size_t count = SkUTF::ToUTF16(unichar, buffer);
|
240
|
+
callback(unichar, before, after, count);
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
template <typename Callback>
|
245
|
+
void forEachCodepoint(const char16_t* utf16, int32_t utf16Units, Callback&& callback) {
|
246
|
+
const char16_t* current = utf16;
|
247
|
+
const char16_t* end = utf16 + utf16Units;
|
248
|
+
while (current < end) {
|
249
|
+
auto before = current - utf16;
|
250
|
+
SkUnichar unichar = SkUTF::NextUTF16((const uint16_t**)¤t, (const uint16_t*)end);
|
251
|
+
auto after = current - utf16;
|
252
|
+
callback(unichar, before, after);
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
template <typename Callback>
|
257
|
+
void forEachBidiRegion(const uint16_t utf16[], int utf16Units, SkBidiIterator::Direction dir, Callback&& callback) {
|
258
|
+
auto iter = makeBidiIterator(utf16, utf16Units, dir);
|
259
|
+
const uint16_t* start16 = utf16;
|
260
|
+
const uint16_t* end16 = utf16 + utf16Units;
|
261
|
+
SkBidiIterator::Level currentLevel = 0;
|
262
|
+
|
263
|
+
SkBidiIterator::Position pos16 = 0;
|
264
|
+
while (pos16 <= iter->getLength()) {
|
265
|
+
auto level = iter->getLevelAt(pos16);
|
266
|
+
if (pos16 == 0) {
|
267
|
+
currentLevel = level;
|
268
|
+
} else if (level != currentLevel) {
|
269
|
+
callback(pos16, start16 - utf16, currentLevel);
|
270
|
+
currentLevel = level;
|
271
|
+
}
|
272
|
+
if (start16 == end16) {
|
273
|
+
break;
|
274
|
+
}
|
275
|
+
SkUnichar u = SkUTF::NextUTF16(&start16, end16);
|
276
|
+
pos16 += SkUTF::ToUTF16(u);
|
277
|
+
}
|
278
|
+
}
|
279
|
+
|
280
|
+
template <typename Callback>
|
281
|
+
void forEachBreak(const char16_t utf16[], int utf16Units, SkUnicode::BreakType type, Callback&& callback) {
|
282
|
+
auto iter = makeBreakIterator(type);
|
283
|
+
iter->setText(utf16, utf16Units);
|
284
|
+
auto pos = iter->first();
|
285
|
+
do {
|
286
|
+
callback(pos, iter->status());
|
287
|
+
pos = iter->next();
|
288
|
+
} while (!iter->isDone());
|
289
|
+
}
|
290
|
+
|
291
|
+
virtual void reorderVisual(const BidiLevel runLevels[], int levelsCount, int32_t logicalFromVisual[]) = 0;
|
292
|
+
|
293
|
+
virtual std::unique_ptr<SkUnicode> copy() = 0;
|
294
|
+
|
295
|
+
static std::unique_ptr<SkUnicode> Make();
|
296
|
+
|
297
|
+
static std::unique_ptr<SkUnicode> MakeIcuBasedUnicode();
|
298
|
+
|
299
|
+
static std::unique_ptr<SkUnicode> MakeClientBasedUnicode(
|
300
|
+
SkSpan<char> text,
|
301
|
+
std::vector<SkUnicode::Position> words,
|
302
|
+
std::vector<SkUnicode::Position> graphemeBreaks,
|
303
|
+
std::vector<SkUnicode::LineBreakBefore> lineBreaks);
|
304
|
+
|
305
|
+
static std::unique_ptr<SkUnicode> MakeLibgraphemeBasedUnicode();
|
306
|
+
};
|
307
|
+
|
308
|
+
namespace sknonstd {
|
309
|
+
template <> struct is_bitmask_enum<SkUnicode::CodeUnitFlags> : std::true_type {};
|
310
|
+
} // namespace sknonstd
|
311
|
+
|
312
|
+
#endif // SkUnicode_DEFINED
|