Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Friends | List of all members
SkUnicode_client Class Reference
Inheritance diagram for SkUnicode_client:
SkUnicodeHardCodedCharProperties SkUnicode SkRefCnt SkRefCntBase

Classes

struct  Data
 

Public Member Functions

 SkUnicode_client ()=delete
 
 SkUnicode_client (SkSpan< char > text, std::vector< SkUnicode::Position > words, std::vector< SkUnicode::Position > graphemeBreaks, std::vector< SkUnicode::LineBreakBefore > lineBreaks)
 
 ~SkUnicode_client () override=default
 
void reset ()
 
std::unique_ptr< SkBidiIteratormakeBidiIterator (const uint16_t text[], int count, SkBidiIterator::Direction dir) override
 
std::unique_ptr< SkBidiIteratormakeBidiIterator (const char text[], int count, SkBidiIterator::Direction dir) override
 
std::unique_ptr< SkBreakIteratormakeBreakIterator (const char locale[], BreakType breakType) override
 
std::unique_ptr< SkBreakIteratormakeBreakIterator (BreakType breakType) override
 
bool getBidiRegions (const char utf8[], int utf8Units, TextDirection dir, std::vector< BidiRegion > *results) override
 
bool getUtf8Words (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 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 getWords (const char utf8[], int utf8Units, const char *locale, std::vector< Position > *results) override
 
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
 
- Public Member Functions inherited from SkUnicodeHardCodedCharProperties
bool isControl (SkUnichar utf8) override
 
bool isWhitespace (SkUnichar utf8) override
 
bool isSpace (SkUnichar utf8) override
 
bool isTabulation (SkUnichar utf8) override
 
bool isHardBreak (SkUnichar utf8) override
 
bool isEmoji (SkUnichar utf8) override
 
bool isEmojiComponent (SkUnichar utf8) override
 
bool isEmojiModifierBase (SkUnichar utf8) override
 
bool isEmojiModifier (SkUnichar utf8) override
 
bool isRegionalIndicator (SkUnichar utf8) override
 
bool isIdeographic (SkUnichar utf8) override
 
- Public Member Functions inherited from SkUnicode
 ~SkUnicode () override=default
 
virtual SkString toUpper (const SkString &)=0
 
virtual SkString toUpper (const SkString &, const char *locale)=0
 
virtual bool isControl (SkUnichar utf8)=0
 
virtual bool isWhitespace (SkUnichar utf8)=0
 
virtual bool isSpace (SkUnichar utf8)=0
 
virtual bool isTabulation (SkUnichar utf8)=0
 
virtual bool isHardBreak (SkUnichar utf8)=0
 
virtual bool isEmoji (SkUnichar utf8)=0
 
virtual bool isEmojiComponent (SkUnichar utf8)=0
 
virtual bool isEmojiModifierBase (SkUnichar utf8)=0
 
virtual bool isEmojiModifier (SkUnichar utf8)=0
 
virtual bool isRegionalIndicator (SkUnichar utf8)=0
 
virtual bool isIdeographic (SkUnichar utf8)=0
 
virtual std::unique_ptr< SkBidiIteratormakeBidiIterator (const uint16_t text[], int count, SkBidiIterator::Direction)=0
 
virtual std::unique_ptr< SkBidiIteratormakeBidiIterator (const char text[], int count, SkBidiIterator::Direction)=0
 
virtual std::unique_ptr< SkBreakIteratormakeBreakIterator (const char locale[], BreakType breakType)=0
 
virtual std::unique_ptr< SkBreakIteratormakeBreakIterator (BreakType type)=0
 
virtual bool getBidiRegions (const char utf8[], int utf8Units, TextDirection dir, std::vector< BidiRegion > *results)=0
 
virtual bool getWords (const char utf8[], int utf8Units, const char *locale, std::vector< Position > *results)=0
 
virtual bool getUtf8Words (const char utf8[], int utf8Units, const char *locale, std::vector< Position > *results)=0
 
virtual bool getSentences (const char utf8[], int utf8Units, const char *locale, std::vector< Position > *results)=0
 
virtual bool computeCodeUnitFlags (char utf8[], int utf8Units, bool replaceTabs, skia_private::TArray< SkUnicode::CodeUnitFlags, true > *results)=0
 
virtual bool computeCodeUnitFlags (char16_t utf16[], int utf16Units, bool replaceTabs, skia_private::TArray< SkUnicode::CodeUnitFlags, true > *results)=0
 
template<typename Callback >
void forEachCodepoint (const char *utf8, int32_t utf8Units, Callback &&callback)
 
template<typename Callback >
void forEachCodepoint (const char16_t *utf16, int32_t utf16Units, Callback &&callback)
 
template<typename Callback >
void forEachBidiRegion (const uint16_t utf16[], int utf16Units, SkBidiIterator::Direction dir, Callback &&callback)
 
template<typename Callback >
void forEachBreak (const char16_t utf16[], int utf16Units, SkUnicode::BreakType type, Callback &&callback)
 
virtual void reorderVisual (const BidiLevel runLevels[], int levelsCount, int32_t logicalFromVisual[])=0
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Friends

class SkBreakIterator_client
 

Additional Inherited Members

- Public Types inherited from SkUnicode
enum  CodeUnitFlags {
  kNoCodeUnitFlag = 0x00 , kPartOfWhiteSpaceBreak = 0x01 , kGraphemeStart = 0x02 , kSoftLineBreakBefore = 0x04 ,
  kHardLineBreakBefore = 0x08 , kPartOfIntraWordBreak = 0x10 , kControl = 0x20 , kTabulation = 0x40 ,
  kGlyphClusterStart = 0x80 , kIdeographic = 0x100 , kEmoji = 0x200 , kWordBreak = 0x400 ,
  kSentenceBreak = 0x800
}
 
enum class  TextDirection { kLTR , kRTL }
 
enum class  LineBreakType { kSoftLineBreak = 0 , kHardLineBreak = 100 }
 
enum class  BreakType { kWords , kGraphemes , kLines , kSentences }
 
typedef size_t Position
 
typedef uint8_t BidiLevel
 
- Static Public Member Functions inherited from SkUnicode
static bool hasTabulationFlag (SkUnicode::CodeUnitFlags flags)
 
static bool hasHardLineBreakFlag (SkUnicode::CodeUnitFlags flags)
 
static bool hasSoftLineBreakFlag (SkUnicode::CodeUnitFlags flags)
 
static bool hasGraphemeStartFlag (SkUnicode::CodeUnitFlags flags)
 
static bool hasControlFlag (SkUnicode::CodeUnitFlags flags)
 
static bool hasPartOfWhiteSpaceBreakFlag (SkUnicode::CodeUnitFlags flags)
 
static bool extractBidi (const char utf8[], int utf8Units, TextDirection dir, std::vector< BidiRegion > *bidiRegions)
 
static SkString convertUtf16ToUtf8 (const char16_t *utf16, int utf16Units)
 
static SkString convertUtf16ToUtf8 (const std::u16string &utf16)
 
static std::u16string convertUtf8ToUtf16 (const char *utf8, int utf8Units)
 
static std::u16string convertUtf8ToUtf16 (const SkString &utf8)
 
template<typename Appender8 , typename Appender16 >
static bool extractUtfConversionMapping (SkSpan< const char > utf8, Appender8 &&appender8, Appender16 &&appender16)
 

Detailed Description

Definition at line 39 of file SkUnicode_client.cpp.

Constructor & Destructor Documentation

◆ SkUnicode_client() [1/2]

SkUnicode_client::SkUnicode_client ( )
delete

◆ SkUnicode_client() [2/2]

SkUnicode_client::SkUnicode_client ( SkSpan< char >  text,
std::vector< SkUnicode::Position words,
std::vector< SkUnicode::Position graphemeBreaks,
std::vector< SkUnicode::LineBreakBefore lineBreaks 
)
inline

Definition at line 66 of file SkUnicode_client.cpp.

70 : fData(std::make_shared<Data>(text,
71 std::move(words),
72 std::move(graphemeBreaks),
73 std::move(lineBreaks))) { }
std::u16string text

◆ ~SkUnicode_client()

SkUnicode_client::~SkUnicode_client ( )
overridedefault

Member Function Documentation

◆ computeCodeUnitFlags() [1/2]

bool SkUnicode_client::computeCodeUnitFlags ( char  utf8[],
int  utf8Units,
bool  replaceTabs,
TArray< SkUnicode::CodeUnitFlags, true > *  results 
)
inlineoverridevirtual

Implements SkUnicode.

Definition at line 111 of file SkUnicode_client.cpp.

114 {
115 results->clear();
116 results->push_back_n(utf8Units + 1, CodeUnitFlags::kNoCodeUnitFlag);
117 for (auto& lineBreak : fData->fLineBreaks) {
118 (*results)[lineBreak.pos] |=
119 lineBreak.breakType == LineBreakType::kHardLineBreak
120 ? CodeUnitFlags::kHardLineBreakBefore
121 : CodeUnitFlags::kSoftLineBreakBefore;
122 }
123 for (auto& grapheme : fData->fGraphemeBreaks) {
124 (*results)[grapheme] |= CodeUnitFlags::kGraphemeStart;
125 }
126 const char* current = utf8;
127 const char* end = utf8 + utf8Units;
128 while (current < end) {
129 auto before = current - utf8;
130 SkUnichar unichar = SkUTF::NextUTF8(&current, end);
131 if (unichar < 0) unichar = 0xFFFD;
132 auto after = current - utf8;
133 if (replaceTabs && this->isTabulation(unichar)) {
134 results->at(before) |= SkUnicode::kTabulation;
135 if (replaceTabs) {
136 unichar = ' ';
137 utf8[before] = ' ';
138 }
139 }
140 for (auto i = before; i < after; ++i) {
141 if (this->isSpace(unichar)) {
143 }
144 if (this->isWhitespace(unichar)) {
146 }
147 if (this->isControl(unichar)) {
148 results->at(i) |= SkUnicode::kControl;
149 }
150 }
151 }
152 return true;
153 }
int32_t SkUnichar
Definition: SkTypes.h:175
bool isTabulation(SkUnichar utf8) override
bool isSpace(SkUnichar utf8) override
bool isControl(SkUnichar utf8) override
bool isWhitespace(SkUnichar utf8) override
@ kPartOfWhiteSpaceBreak
Definition: SkUnicode.h:81
@ kTabulation
Definition: SkUnicode.h:87
@ kControl
Definition: SkUnicode.h:86
@ kPartOfIntraWordBreak
Definition: SkUnicode.h:85
T * push_back_n(int n)
Definition: SkTArray.h:267
glong glong end
SK_SPI SkUnichar NextUTF8(const char **ptr, const char *end)
Definition: SkUTF.cpp:118

◆ computeCodeUnitFlags() [2/2]

bool SkUnicode_client::computeCodeUnitFlags ( char16_t  utf16[],
int  utf16Units,
bool  replaceTabs,
TArray< SkUnicode::CodeUnitFlags, true > *  results 
)
inlineoverridevirtual

Implements SkUnicode.

Definition at line 155 of file SkUnicode_client.cpp.

156 {
157 results->clear();
158 results->push_back_n(utf16Units + 1, CodeUnitFlags::kNoCodeUnitFlag);
159 for (auto& lineBreak : fData->fLineBreaks) {
160 (*results)[lineBreak.pos] |=
161 lineBreak.breakType == LineBreakType::kHardLineBreak
162 ? CodeUnitFlags::kHardLineBreakBefore
163 : CodeUnitFlags::kSoftLineBreakBefore;
164 }
165 for (auto& grapheme : fData->fGraphemeBreaks) {
166 (*results)[grapheme] |= CodeUnitFlags::kGraphemeStart;
167 }
168 return true;
169 }

◆ getBidiRegions()

bool SkUnicode_client::getBidiRegions ( const char  utf8[],
int  utf8Units,
TextDirection  dir,
std::vector< BidiRegion > *  results 
)
inlineoverridevirtual

Implements SkUnicode.

Definition at line 88 of file SkUnicode_client.cpp.

91 {
92 return fBidiFact->ExtractBidi(utf8, utf8Units, dir, results);
93 }
bool ExtractBidi(const char utf8[], int utf8Units, SkUnicode::TextDirection dir, std::vector< SkUnicode::BidiRegion > *bidiRegions) const
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
Definition: switches.h:145

◆ getSentences()

bool SkUnicode_client::getSentences ( const char  utf8[],
int  utf8Units,
const char *  locale,
std::vector< SkUnicode::Position > *  results 
)
inlineoverridevirtual

Implements SkUnicode.

Definition at line 103 of file SkUnicode_client.cpp.

106 {
107 SkDEBUGF("Method 'getSentences' is not implemented\n");
108 return false;
109 }
#define SkDEBUGF(...)
Definition: SkDebug.h:24

◆ getUtf8Words()

bool SkUnicode_client::getUtf8Words ( const char  utf8[],
int  utf8Units,
const char *  locale,
std::vector< Position > *  results 
)
inlineoverridevirtual

Implements SkUnicode.

Definition at line 95 of file SkUnicode_client.cpp.

98 {
99 SkDEBUGF("Method 'getUtf8Words' is not implemented\n");
100 return false;
101 }

◆ getWords()

bool SkUnicode_client::getWords ( const char  utf8[],
int  utf8Units,
const char *  locale,
std::vector< Position > *  results 
)
inlineoverridevirtual

Implements SkUnicode.

Definition at line 171 of file SkUnicode_client.cpp.

171 {
172 *results = fData->fWords;
173 return true;
174 }

◆ makeBidiIterator() [1/2]

std::unique_ptr< SkBidiIterator > SkUnicode_client::makeBidiIterator ( const char  text[],
int  count,
SkBidiIterator::Direction  dir 
)
overridevirtual

Implements SkUnicode.

Definition at line 237 of file SkUnicode_client.cpp.

239 {
240 return fBidiFact->MakeIterator(text, count, dir);
241}
int count
Definition: FontMgrTest.cpp:50
std::unique_ptr< SkBidiIterator > MakeIterator(const uint16_t utf16[], int utf16Units, SkBidiIterator::Direction dir) const

◆ makeBidiIterator() [2/2]

std::unique_ptr< SkBidiIterator > SkUnicode_client::makeBidiIterator ( const uint16_t  text[],
int  count,
SkBidiIterator::Direction  dir 
)
overridevirtual

Implements SkUnicode.

Definition at line 233 of file SkUnicode_client.cpp.

234 {
235 return fBidiFact->MakeIterator(text, count, dir);
236}

◆ makeBreakIterator() [1/2]

std::unique_ptr< SkBreakIterator > SkUnicode_client::makeBreakIterator ( BreakType  breakType)
overridevirtual

Implements SkUnicode.

Definition at line 246 of file SkUnicode_client.cpp.

246 {
247 return std::make_unique<SkBreakIterator_client>(fData);
248}

◆ makeBreakIterator() [2/2]

std::unique_ptr< SkBreakIterator > SkUnicode_client::makeBreakIterator ( const char  locale[],
BreakType  breakType 
)
overridevirtual

Implements SkUnicode.

Definition at line 242 of file SkUnicode_client.cpp.

243 {
244 return std::make_unique<SkBreakIterator_client>(fData);
245}

◆ reorderVisual()

void SkUnicode_client::reorderVisual ( const BidiLevel  runLevels[],
int  levelsCount,
int32_t  logicalFromVisual[] 
)
inlineoverridevirtual

Implements SkUnicode.

Definition at line 184 of file SkUnicode_client.cpp.

186 {
187 fBidiFact->bidi_reorderVisual(runLevels, levelsCount, logicalFromVisual);
188 }
virtual void bidi_reorderVisual(const SkUnicode::BidiLevel runLevels[], int levelsCount, int32_t logicalFromVisual[]) const =0

◆ reset()

void SkUnicode_client::reset ( )
inline

Definition at line 77 of file SkUnicode_client.cpp.

77{ fData->reset(); }

◆ toUpper() [1/2]

SkString SkUnicode_client::toUpper ( const SkString str)
inlineoverridevirtual

Implements SkUnicode.

Definition at line 176 of file SkUnicode_client.cpp.

176 {
177 return this->toUpper(str, nullptr);
178 }
SkString toUpper(const SkString &str) override

◆ toUpper() [2/2]

SkString SkUnicode_client::toUpper ( const SkString str,
const char *  locale 
)
inlineoverridevirtual

Implements SkUnicode.

Definition at line 180 of file SkUnicode_client.cpp.

180 {
181 return SkString(fData->fText8.data(), fData->fText8.size());
182 }

Friends And Related Function Documentation

◆ SkBreakIterator_client

friend class SkBreakIterator_client
friend

Definition at line 190 of file SkUnicode_client.cpp.


The documentation for this class was generated from the following file: