26#include <unordered_map>
48 std::vector<BidiRegion>* results)
override {
55 std::vector<SkUnicode::Position>* results)
override {
56 SkDEBUGF(
"Method 'getSentences' is not implemented\n");
65 results->
push_back_n(utf8Units + 1, CodeUnitFlags::kNoCodeUnitFlag);
68 (*results)[lineBreak] |= CodeUnitFlags::kSoftLineBreakBefore;
69 while (lineBreak < utf8Units) {
70 lineBreak += grapheme_next_line_break_utf8(
utf8 + lineBreak, utf8Units - lineBreak);
72 auto codePoint =
utf8[lineBreak - 1];
73 (*results)[lineBreak] |= this->
isHardBreak(codePoint)
74 ? CodeUnitFlags::kHardLineBreakBefore
75 : CodeUnitFlags::kSoftLineBreakBefore;
77 (*results)[utf8Units] |= CodeUnitFlags::kSoftLineBreakBefore;
79 size_t graphemeBreak = 0;
80 (*results)[graphemeBreak] |= CodeUnitFlags::kGraphemeStart;
81 while (graphemeBreak < utf8Units) {
82 graphemeBreak += grapheme_next_character_break_utf8(
utf8 + graphemeBreak, utf8Units - graphemeBreak);
83 (*results)[graphemeBreak] |= CodeUnitFlags::kGraphemeStart;
86 const char* current =
utf8;
87 const char*
end =
utf8 + utf8Units;
88 while (current <
end) {
89 auto before = current -
utf8;
91 if (unichar < 0) unichar = 0xFFFD;
92 auto after = current -
utf8;
100 for (
auto i = before;
i < after; ++
i) {
123 const char* ptr8 =
utf8;
124 const char* end8 =
utf8 + utf8Units;
125 while (ptr8 < end8) {
126 results->emplace(ptr8 -
utf8, utf16Units);
139 results->emplace(utf8Units, utf16Units);
143 bool getWords(
const char utf8[],
int utf8Units,
const char* locale, std::vector<Position>* results)
override {
144 std::unordered_map<Position, Position> mapping;
148 size_t wordBreak = 0;
149 while (wordBreak < utf8Units) {
150 wordBreak += grapheme_next_word_break_utf8(
utf8 + wordBreak, utf8Units - wordBreak);
151 if (mapping.find(wordBreak) == mapping.end()) {
154 results->emplace_back(mapping[wordBreak]);
162 std::vector<Position>* results)
override {
164 std::vector<CodeUnitFlags> breaks(utf8Units + 1, CodeUnitFlags::kNoCodeUnitFlag);
166 size_t lineBreak = 0;
167 breaks[lineBreak] = CodeUnitFlags::kSoftLineBreakBefore;
168 while (lineBreak < utf8Units) {
169 lineBreak += grapheme_next_line_break_utf8(
utf8 + lineBreak, utf8Units - lineBreak);
170 breaks[lineBreak] = CodeUnitFlags::kSoftLineBreakBefore;
172 breaks[lineBreak] = CodeUnitFlags::kSoftLineBreakBefore;
174 const char* current =
utf8;
175 const char*
end =
utf8 + utf8Units;
176 while (current <
end) {
177 auto index = current -
utf8;
180 breaks[index] = CodeUnitFlags::kPartOfWhiteSpaceBreak;
186 bool whitespaces =
false;
187 for (
size_t i = 0;
i < breaks.size(); ++
i) {
189 if (
b == CodeUnitFlags::kSoftLineBreakBefore) {
190 results->emplace_back(
i);
193 results->emplace_back(
i);
195 }
else if (
b == CodeUnitFlags::kPartOfWhiteSpaceBreak) {
197 results->emplace_back(
i);
218 return this->
toUpper(str,
nullptr);
229 int32_t logicalFromVisual[])
override {
240 std::vector<SkUnicode::LineBreakBefore> fLineBreaks;
242 static constexpr const int kDone = -1;
246 {
return fLineBreaks[(fLineBreakIndex = 0)].
pos; }
248 {
return fLineBreaks[fLineBreakIndex].pos; }
250 {
return fLineBreaks[++fLineBreakIndex].pos; }
252 return fLineBreaks[fLineBreakIndex].breakType ==
254 ? SkUnicode::CodeUnitFlags::kHardLineBreakBefore
255 : SkUnicode::CodeUnitFlags::kSoftLineBreakBefore;
257 bool isDone()
override {
return fLineBreaks[fLineBreakIndex].pos == kDone; }
258 bool setText(
const char utftext8[],
int utf8Units)
override {
260 size_t lineBreak = 0;
263 for (
size_t pos = 0;
pos < utf8Units;) {
264 pos += grapheme_next_line_break_utf8(utftext8 +
pos, utf8Units -
pos);
265 auto codePoint = utftext8[
pos];
266 fLineBreaks.emplace_back(
pos,
276 bool setText(
const char16_t utftext16[],
int utf16Units)
override {
293 return std::make_unique<SkBreakIterator_libgrapheme>(
this);
296 return std::make_unique<SkBreakIterator_libgrapheme>(
this);
301 return sk_make_sp<SkUnicode_libgrapheme>();
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
Position current() override
Position first() override
bool setText(const char16_t utftext16[], int utf16Units) override
SkBreakIterator_libgrapheme(SkUnicode_libgrapheme *unicode)
bool setText(const char utftext8[], int utf8Units) override
const char * data() const
bool isTabulation(SkUnichar utf8) override
bool isIdeographic(SkUnichar utf8) override
bool isSpace(SkUnichar utf8) override
bool isHardBreak(SkUnichar utf8) override
bool isControl(SkUnichar utf8) override
bool isWhitespace(SkUnichar utf8) override
bool getUtf8Words(const char utf8[], int utf8Units, const char *locale, std::vector< Position > *results) override
bool computeCodeUnitFlags(char utf8[], int utf8Units, bool replaceTabs, skia_private::TArray< SkUnicode::CodeUnitFlags, true > *results) override
bool getUtf8To16Mapping(const char utf8[], int utf8Units, std::unordered_map< Position, Position > *results)
SkString toUpper(const SkString &str) override
SkString toUpper(const SkString &str, const char *locale) override
void reorderVisual(const BidiLevel runLevels[], int levelsCount, int32_t logicalFromVisual[]) override
bool computeCodeUnitFlags(char16_t utf16[], int utf16Units, bool replaceTabs, skia_private::TArray< SkUnicode::CodeUnitFlags, true > *results) override
~SkUnicode_libgrapheme() override=default
std::unique_ptr< SkBidiIterator > makeBidiIterator(const uint16_t text[], int count, SkBidiIterator::Direction dir) override
bool getWords(const char utf8[], int utf8Units, const char *locale, std::vector< Position > *results) override
bool getSentences(const char utf8[], int utf8Units, const char *locale, std::vector< SkUnicode::Position > *results) override
bool getBidiRegions(const char utf8[], int utf8Units, TextDirection dir, std::vector< BidiRegion > *results) override
std::unique_ptr< SkBreakIterator > makeBreakIterator(const char locale[], BreakType breakType) override
SK_SPI SkUnichar NextUTF8(const char **ptr, const char *end)
SK_SPI size_t ToUTF16(SkUnichar uni, uint16_t utf16[2]=nullptr)
SKUNICODE_API sk_sp< SkUnicode > Make()
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