1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
diff --git a/modules/skparagraph/BUILD.gn b/modules/skparagraph/BUILD.gn
index 283eeacebd..742fe4552f 100644
--- a/modules/skparagraph/BUILD.gn
+++ b/modules/skparagraph/BUILD.gn
@@ -20,6 +20,9 @@ if (skia_enable_skparagraph && skia_enable_skshaper && skia_enable_skunicode &&
"include",
"utils",
]
+ if (is_component_build) {
+ defines += [ "SKPARAGRAPH_DLL" ]
+ }
}
skia_component("skparagraph") {
@@ -27,6 +30,7 @@ if (skia_enable_skparagraph && skia_enable_skshaper && skia_enable_skunicode &&
public_configs = [ ":public_config" ]
public = skparagraph_core_public
sources = skparagraph_core_sources
+ defines = [ "SKPARAGRAPH_IMPLEMENTATION=1" ]
public_deps = [
"../..:skia",
"../skunicode",
diff --git a/modules/skparagraph/include/FontCollection.h b/modules/skparagraph/include/FontCollection.h
index ae2f9922d0..5b77e997bc 100644
--- a/modules/skparagraph/include/FontCollection.h
+++ b/modules/skparagraph/include/FontCollection.h
@@ -16,9 +16,29 @@
namespace skia {
namespace textlayout {
+#if !defined(SKPARAGRAPH_IMPLEMENTATION)
+ #define SKPARAGRAPH_IMPLEMENTATION 0
+#endif
+
+#if !defined(SKPARAGRAPH_API)
+ #if defined(SKPARAGRAPH_DLL)
+ #if defined(_MSC_VER)
+ #if SKPARAGRAPH_IMPLEMENTATION
+ #define SKPARAGRAPH_API __declspec(dllexport)
+ #else
+ #define SKPARAGRAPH_API __declspec(dllimport)
+ #endif
+ #else
+ #define SKPARAGRAPH_API __attribute__((visibility("default")))
+ #endif
+ #else
+ #define SKPARAGRAPH_API
+ #endif
+#endif
+
class TextStyle;
class Paragraph;
-class FontCollection : public SkRefCnt {
+class SKPARAGRAPH_API FontCollection : public SkRefCnt {
public:
FontCollection();
diff --git a/modules/skparagraph/include/ParagraphBuilder.h b/modules/skparagraph/include/ParagraphBuilder.h
index feac5622bb..72712e121d 100644
--- a/modules/skparagraph/include/ParagraphBuilder.h
+++ b/modules/skparagraph/include/ParagraphBuilder.h
@@ -16,7 +16,27 @@
namespace skia {
namespace textlayout {
-class ParagraphBuilder {
+#if !defined(SKPARAGRAPH_IMPLEMENTATION)
+ #define SKPARAGRAPH_IMPLEMENTATION 0
+#endif
+
+#if !defined(SKPARAGRAPH_API)
+ #if defined(SKPARAGRAPH_DLL)
+ #if defined(_MSC_VER)
+ #if SKPARAGRAPH_IMPLEMENTATION
+ #define SKPARAGRAPH_API __declspec(dllexport)
+ #else
+ #define SKPARAGRAPH_API __declspec(dllimport)
+ #endif
+ #else
+ #define SKPARAGRAPH_API __attribute__((visibility("default")))
+ #endif
+ #else
+ #define SKPARAGRAPH_API
+ #endif
+#endif
+
+class SKPARAGRAPH_API ParagraphBuilder {
protected:
ParagraphBuilder() {}
diff --git a/modules/skparagraph/include/ParagraphStyle.h b/modules/skparagraph/include/ParagraphStyle.h
index 98ec228ffb..63e973c7db 100644
--- a/modules/skparagraph/include/ParagraphStyle.h
+++ b/modules/skparagraph/include/ParagraphStyle.h
@@ -18,6 +18,26 @@
namespace skia {
namespace textlayout {
+#if !defined(SKPARAGRAPH_IMPLEMENTATION)
+ #define SKPARAGRAPH_IMPLEMENTATION 0
+#endif
+
+#if !defined(SKPARAGRAPH_API)
+ #if defined(SKPARAGRAPH_DLL)
+ #if defined(_MSC_VER)
+ #if SKPARAGRAPH_IMPLEMENTATION
+ #define SKPARAGRAPH_API __declspec(dllexport)
+ #else
+ #define SKPARAGRAPH_API __declspec(dllimport)
+ #endif
+ #else
+ #define SKPARAGRAPH_API __attribute__((visibility("default")))
+ #endif
+ #else
+ #define SKPARAGRAPH_API
+ #endif
+#endif
+
struct StrutStyle {
StrutStyle();
@@ -75,7 +95,7 @@ private:
bool fHalfLeading;
};
-struct ParagraphStyle {
+struct SKPARAGRAPH_API ParagraphStyle {
ParagraphStyle();
bool operator==(const ParagraphStyle& rhs) const {
diff --git a/modules/skparagraph/include/TextStyle.h b/modules/skparagraph/include/TextStyle.h
index 4bc2fb9dbc..4bee210fb7 100644
--- a/modules/skparagraph/include/TextStyle.h
+++ b/modules/skparagraph/include/TextStyle.h
@@ -21,6 +21,26 @@
namespace skia {
namespace textlayout {
+#if !defined(SKPARAGRAPH_IMPLEMENTATION)
+ #define SKPARAGRAPH_IMPLEMENTATION 0
+#endif
+
+#if !defined(SKPARAGRAPH_API)
+ #if defined(SKPARAGRAPH_DLL)
+ #if defined(_MSC_VER)
+ #if SKPARAGRAPH_IMPLEMENTATION
+ #define SKPARAGRAPH_API __declspec(dllexport)
+ #else
+ #define SKPARAGRAPH_API __declspec(dllimport)
+ #endif
+ #else
+ #define SKPARAGRAPH_API __attribute__((visibility("default")))
+ #endif
+ #else
+ #define SKPARAGRAPH_API
+ #endif
+#endif
+
static inline bool nearlyZero(SkScalar x, SkScalar tolerance = SK_ScalarNearlyZero) {
if (SkIsFinite(x)) {
return SkScalarNearlyZero(x, tolerance);
@@ -148,9 +168,9 @@ struct PlaceholderStyle {
SkScalar fBaselineOffset = 0;
};
-class TextStyle {
+class SKPARAGRAPH_API TextStyle {
public:
- TextStyle() = default;
+ TextStyle();
TextStyle(const TextStyle& other) = default;
TextStyle& operator=(const TextStyle& other) = default;
@@ -288,8 +308,6 @@ public:
void setPlaceholder() { fIsPlaceholder = true; }
private:
- static const std::vector<SkString>* kDefaultFontFamilies;
-
Decoration fDecoration = {
TextDecoration::kNoDecoration,
// TODO: switch back to kGaps when (if) switching flutter to skparagraph
@@ -302,7 +320,7 @@ private:
SkFontStyle fFontStyle;
- std::vector<SkString> fFontFamilies = *kDefaultFontFamilies;
+ std::vector<SkString> fFontFamilies;
SkScalar fFontSize = 14.0;
SkScalar fHeight = 1.0;
diff --git a/modules/skparagraph/src/TextStyle.cpp b/modules/skparagraph/src/TextStyle.cpp
index 492f94fe10..9889cc90aa 100644
--- a/modules/skparagraph/src/TextStyle.cpp
+++ b/modules/skparagraph/src/TextStyle.cpp
@@ -6,9 +6,13 @@
namespace skia {
namespace textlayout {
-const std::vector<SkString>* TextStyle::kDefaultFontFamilies =
+static const std::vector<SkString>* kDefaultFontFamilies =
new std::vector<SkString>{SkString(DEFAULT_FONT_FAMILY)};
+TextStyle::TextStyle() : fFontFamilies(*kDefaultFontFamilies)
+{
+}
+
TextStyle TextStyle::cloneForPlaceholder() {
TextStyle result;
result.fColor = fColor;
diff --git a/modules/skparagraph/utils/TestFontCollection.cpp b/modules/skparagraph/utils/TestFontCollection.cpp
index b74a3b99cf..3fe2b129da 100644
--- a/modules/skparagraph/utils/TestFontCollection.cpp
+++ b/modules/skparagraph/utils/TestFontCollection.cpp
@@ -57,6 +57,8 @@ bool TestFontCollection::addFontFromFile(const std::string& path, const std::str
if (!file) {
return false;
}
+
+#if 0
#if defined(SK_TYPEFACE_FACTORY_FREETYPE)
sk_sp<SkTypeface> face =
SkTypeface_FreeType::MakeFromStream(std::move(file), SkFontArguments());
@@ -72,6 +74,7 @@ bool TestFontCollection::addFontFromFile(const std::string& path, const std::str
} else {
fFontProvider->registerTypeface(std::move(face), SkString(familyName.c_str()));
}
+#endif
return true;
}
|