#include <stdbool.h>
Go to the source code of this file.
◆ cleanup_unicode_impl()
void cleanup_unicode_impl |
( |
| ) |
|
Definition at line 40 of file bridge.cpp.
40 {
41 if (gUnicode == nullptr) {
42 SkDebugf(
"Unicode object does not exist\n");
43 return;
44 }
45 delete gUnicode.get();
46}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
◆ getFlags()
Definition at line 68 of file bridge.cpp.
68 {
69 if (gUnicode == nullptr) {
70 SK_ABORT(
"Unicode object does not exist");
71 } else if (gCodeUnitFlags.size() == 0) {
72 SK_ABORT(
"Unicode object is empty or not initialized\n");
73 } else if (index < 0 || index >= gCodeUnitFlags.size()) {
74 SK_ABORT(
"Index value %d outside of valid range [%d:%d)\n", index, 0, gCodeUnitFlags.size());
75 }
76 return gCodeUnitFlags[index];
77}
#define SK_ABORT(message,...)
◆ getSentences()
void * getSentences |
( |
char * |
text, |
|
|
int * |
length |
|
) |
| |
Definition at line 79 of file bridge.cpp.
79 {
80 if (gUnicode == nullptr) {
81 SkDebugf(
"Unicode object does not exist");
82 return nullptr;
83 }
84
85 gSentences.clear();
86 gUnicode->getSentences(
text, strlen(
text),
nullptr, &gSentences);
87 *
length = gSentences.size();
88
90}
◆ init_skunicode_impl()
bool init_skunicode_impl |
( |
char * |
impl | ) |
|
Definition at line 19 of file bridge.cpp.
19 {
20
22 if (unicodeName.equals("icu")) {
24 } else if (unicodeName.equals("icu4x")) {
26 } else if (unicodeName.equals("libgrapheme")) {
28 } else {
29 SkDebugf(
"Implementation '%s' not supported\n", impl);
30 return false;
31 }
32 auto ptr = reinterpret_cast<void*>(gUnicode.get());
33 if (ptr == nullptr) {
34 SkDebugf(
"Could not create Unicode object\n");
35 return false;
36 }
37 return true;
38}
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
◆ perf_compute_codeunit_flags()
double perf_compute_codeunit_flags |
( |
char * |
text | ) |
|
Definition at line 48 of file bridge.cpp.
48 {
49 if (gUnicode == nullptr) {
50 SkDebugf(
"Unicode object does not exist\n");
51 return -1;
52 }
54 gUnicode->computeCodeUnitFlags(
text, strlen(
text),
false, &gCodeUnitFlags);
55 if (gCodeUnitFlags.size() < strlen(
text)) {
56 SkDebugf(
"computeCodeUnitFlags failed: %d < %zu\n%s\n\n\n", gCodeUnitFlags.size(), strlen(
text),
text);
57 return -1;
58 }
59 std::vector<SkUnicode::Position> positions;
60 gUnicode->getUtf8Words(
text, strlen(
text),
nullptr, &positions);
62 for (
auto pos : positions) {
63 gCodeUnitFlags[
pos] |= SkUnicode::CodeUnitFlags::kWordBreak;
64 }
66}
static double time(int loops, Benchmark *bench, Target *target)
◆ print()
◆ toUpper()
void * toUpper |
( |
char * |
str | ) |
|
Definition at line 117 of file bridge.cpp.
117 {
118 if (gUnicode == nullptr) {
119 SkDebugf(
"Unicode object does not exist");
120 return nullptr;
121 }
123 return reinterpret_cast<void*>(res);
124}
◆ trimSentence()
bool trimSentence |
( |
char * |
text, |
|
|
int * |
sentence, |
|
|
int |
wordLimit |
|
) |
| |
Definition at line 92 of file bridge.cpp.
92 {
93 *sentence = 0;
94 if (gUnicode == nullptr) {
95 SkDebugf(
"Unicode object does not exist");
96 return true;
97 }
98
99 gWords.clear();
100 gUnicode->getUtf8Words(
text, strlen(
text),
nullptr, &gWords);
101
102 for (
auto word : gWords) {
103 if (
word > wordLimit) {
104 return true;
105 } else {
107 }
108 }
109 if (strlen(
text) <= wordLimit) {
110 *sentence = strlen(
text);
111 return false;
112 }
113 return true;
114}