28#include <unicode/ubidi.h>
29#include <unicode/ubrk.h>
30#include <unicode/uchar.h>
31#include <unicode/uloc.h>
32#include <unicode/uscript.h>
33#include <unicode/ustring.h>
34#include <unicode/utext.h>
35#include <unicode/utypes.h>
48 std::vector<SkUnicode::Position> words,
49 std::vector<SkUnicode::Position> graphemeBreaks,
50 std::vector<SkUnicode::LineBreakBefore> lineBreaks)
67 std::vector<SkUnicode::Position> words,
68 std::vector<SkUnicode::Position> graphemeBreaks,
69 std::vector<SkUnicode::LineBreakBefore> lineBreaks)
72 std::move(graphemeBreaks),
73 std::move(lineBreaks))) { }
77 void reset() { fData->reset(); }
91 std::vector<BidiRegion>* results)
override {
98 std::vector<Position>* results)
override {
99 SkDEBUGF(
"Method 'getUtf8Words' is not implemented\n");
106 std::vector<SkUnicode::Position>* results)
override {
107 SkDEBUGF(
"Method 'getSentences' is not implemented\n");
116 results->
push_back_n(utf8Units + 1, CodeUnitFlags::kNoCodeUnitFlag);
117 for (
auto& lineBreak : fData->fLineBreaks) {
118 (*results)[lineBreak.pos] |=
120 ? CodeUnitFlags::kHardLineBreakBefore
121 : CodeUnitFlags::kSoftLineBreakBefore;
123 for (
auto& grapheme : fData->fGraphemeBreaks) {
124 (*results)[grapheme] |= CodeUnitFlags::kGraphemeStart;
126 const char* current =
utf8;
127 const char*
end =
utf8 + utf8Units;
128 while (current <
end) {
129 auto before = current -
utf8;
131 if (unichar < 0) unichar = 0xFFFD;
132 auto after = current -
utf8;
140 for (
auto i = before;
i < after; ++
i) {
158 results->
push_back_n(utf16Units + 1, CodeUnitFlags::kNoCodeUnitFlag);
159 for (
auto& lineBreak : fData->fLineBreaks) {
160 (*results)[lineBreak.pos] |=
162 ? CodeUnitFlags::kHardLineBreakBefore
163 : CodeUnitFlags::kSoftLineBreakBefore;
165 for (
auto& grapheme : fData->fGraphemeBreaks) {
166 (*results)[grapheme] |= CodeUnitFlags::kGraphemeStart;
171 bool getWords(
const char utf8[],
int utf8Units,
const char* locale, std::vector<Position>* results)
override {
172 *results = fData->fWords;
177 return this->
toUpper(str,
nullptr);
181 return SkString(fData->fText8.data(), fData->fText8.size());
186 int32_t logicalFromVisual[])
override {
192 std::shared_ptr<Data> fData;
197 std::shared_ptr<SkUnicode_client::Data> fData;
204 {
return fData->fLineBreaks[fStart + (fLastResult = 0)].
pos; }
206 {
return fData->fLineBreaks[fStart + fLastResult].pos; }
208 {
return fData->fLineBreaks[fStart + fLastResult + 1].pos; }
210 return fData->fLineBreaks[fStart + fLastResult].breakType ==
212 ? SkUnicode::CodeUnitFlags::kHardLineBreakBefore
213 : SkUnicode::CodeUnitFlags::kSoftLineBreakBefore;
215 bool isDone()
override {
return fStart + fLastResult == fEnd; }
216 bool setText(
const char utftext8[],
int utf8Units)
override {
217 SkASSERT(utftext8 >= fData->fText8.data() &&
218 utf8Units <=
SkToS16(fData->fText8.size()));
219 fStart = utftext8 - fData->fText8.data();
220 fEnd = fStart + utf8Units;
224 bool setText(
const char16_t utftext16[],
int utf16Units)
override {
225 SkASSERT(utftext16 >= fData->fText16.data() &&
226 utf16Units <=
SkToS16(fData->fText16.size()));
227 fStart = utftext16 - fData->fText16.data();
228 fEnd = fStart + utf16Units;
244 return std::make_unique<SkBreakIterator_client>(fData);
247 return std::make_unique<SkBreakIterator_client>(fData);
253 std::vector<SkUnicode::Position> words,
254 std::vector<SkUnicode::Position> graphemeBreaks,
255 std::vector<SkUnicode::LineBreakBefore> lineBreaks) {
256 return sk_make_sp<SkUnicode_client>(
text,
258 std::move(graphemeBreaks),
259 std::move(lineBreaks));
constexpr int16_t SkToS16(S x)
bool ExtractBidi(const char utf8[], int utf8Units, SkUnicode::TextDirection dir, std::vector< SkUnicode::BidiRegion > *bidiRegions) const
virtual void bidi_reorderVisual(const SkUnicode::BidiLevel runLevels[], int levelsCount, int32_t logicalFromVisual[]) const =0
std::unique_ptr< SkBidiIterator > MakeIterator(const uint16_t utf16[], int utf16Units, SkBidiIterator::Direction dir) const
SkBreakIterator_client(std::shared_ptr< SkUnicode_client::Data > data)
Position first() override
bool setText(const char16_t utftext16[], int utf16Units) override
bool setText(const char utftext8[], int utf8Units) override
Position current() override
bool isTabulation(SkUnichar utf8) override
bool isSpace(SkUnichar utf8) override
bool isControl(SkUnichar utf8) override
bool isWhitespace(SkUnichar utf8) override
bool getBidiRegions(const char utf8[], int utf8Units, TextDirection dir, std::vector< BidiRegion > *results) override
SkUnicode_client(SkSpan< char > text, std::vector< SkUnicode::Position > words, std::vector< SkUnicode::Position > graphemeBreaks, std::vector< SkUnicode::LineBreakBefore > lineBreaks)
void reorderVisual(const BidiLevel runLevels[], int levelsCount, int32_t logicalFromVisual[]) override
std::unique_ptr< SkBidiIterator > makeBidiIterator(const uint16_t text[], int count, SkBidiIterator::Direction dir) override
SkString toUpper(const SkString &str, const char *locale) override
bool getSentences(const char utf8[], int utf8Units, const char *locale, std::vector< SkUnicode::Position > *results) override
SkUnicode_client()=delete
~SkUnicode_client() override=default
SkString toUpper(const SkString &str) override
bool computeCodeUnitFlags(char utf8[], int utf8Units, bool replaceTabs, TArray< SkUnicode::CodeUnitFlags, true > *results) override
bool computeCodeUnitFlags(char16_t utf16[], int utf16Units, bool replaceTabs, TArray< SkUnicode::CodeUnitFlags, true > *results) override
bool getUtf8Words(const char utf8[], int utf8Units, const char *locale, std::vector< Position > *results) override
std::unique_ptr< SkBreakIterator > makeBreakIterator(const char locale[], BreakType breakType) override
bool getWords(const char utf8[], int utf8Units, const char *locale, std::vector< Position > *results) override
SK_SPI SkUnichar NextUTF8(const char **ptr, const char *end)
SKUNICODE_API sk_sp< SkUnicode > Make(SkSpan< char > text, std::vector< SkUnicode::Position > words, std::vector< SkUnicode::Position > graphemeBreaks, std::vector< SkUnicode::LineBreakBefore > lineBreaks)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
SkSpan< const char16_t > fText16
Data(SkSpan< char > text, std::vector< SkUnicode::Position > words, std::vector< SkUnicode::Position > graphemeBreaks, std::vector< SkUnicode::LineBreakBefore > lineBreaks)
std::vector< Position > fWords
std::vector< SkUnicode::Position > fGraphemeBreaks
SkSpan< const char > fText8
std::vector< SkUnicode::LineBreakBefore > fLineBreaks
std::shared_ptr< const fml::Mapping > data