Flutter Engine
The Flutter Engine
SkUnicode_hardcoded.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
10#include <algorithm>
11#include <array>
12#include <utility>
13
15 return (utf8 < ' ') || (utf8 >= 0x7f && utf8 <= 0x9f) ||
16 (utf8 >= 0x200D && utf8 <= 0x200F) ||
17 (utf8 >= 0x202A && utf8 <= 0x202E);
18}
19
21 static constexpr std::array<SkUnichar, 21> whitespaces {
22 0x0009, // character tabulation
23 0x000A, // line feed
24 0x000B, // line tabulation
25 0x000C, // form feed
26 0x000D, // carriage return
27 0x0020, // space
28 //0x0085, // next line
29 //0x00A0, // no-break space
30 0x1680, // ogham space mark
31 0x2000, // en quad
32 0x2001, // em quad
33 0x2002, // en space
34 0x2003, // em space
35 0x2004, // three-per-em space
36 0x2005, // four-per-em space
37 0x2006, // six-per-em space
38 //0x2007, // figure space
39 0x2008, // punctuation space
40 0x2009, // thin space
41 0x200A, // hair space
42 0x2028, // line separator
43 0x2029, // paragraph separator
44 //0x202F, // narrow no-break space
45 0x205F, // medium mathematical space
46 0x3000};// ideographic space
47 return std::find(whitespaces.begin(), whitespaces.end(), unichar) != whitespaces.end();
48}
49
51 static constexpr std::array<SkUnichar, 25> spaces {
52 0x0009, // character tabulation
53 0x000A, // line feed
54 0x000B, // line tabulation
55 0x000C, // form feed
56 0x000D, // carriage return
57 0x0020, // space
58 0x0085, // next line
59 0x00A0, // no-break space
60 0x1680, // ogham space mark
61 0x2000, // en quad
62 0x2001, // em quad
63 0x2002, // en space
64 0x2003, // em space
65 0x2004, // three-per-em space
66 0x2005, // four-per-em space
67 0x2006, // six-per-em space
68 0x2007, // figure space
69 0x2008, // punctuation space
70 0x2009, // thin space
71 0x200A, // hair space
72 0x2028, // line separator
73 0x2029, // paragraph separator
74 0x202F, // narrow no-break space
75 0x205F, // medium mathematical space
76 0x3000}; // ideographic space
77 return std::find(spaces.begin(), spaces.end(), unichar) != spaces.end();
78}
79
81 return utf8 == '\t';
82}
83
85 return utf8 == '\n' || utf8 == u'\u2028';
86}
87
89 SkDEBUGFAIL("isEmoji Not implemented");
90 return false;
91}
92
94 SkDEBUGFAIL("isEmojiComponent Not implemented");
95 return false;
96}
97
99 SkDEBUGFAIL("isEmojiModifier Not implemented");
100 return false;
101}
102
104 SkDEBUGFAIL("isEmojiModifierBase Not implemented");
105 return false;
106}
107
109 SkDEBUGFAIL("isRegionalIndicator Not implemented");
110 return false;
111}
112
114 static constexpr std::array<std::pair<SkUnichar, SkUnichar>, 8> ranges {{
115 {4352, 4607}, // Hangul Jamo
116 {11904, 42191}, // CJK_Radicals
117 {43072, 43135}, // Phags_Pa
118 {44032, 55215}, // Hangul_Syllables
119 {63744, 64255}, // CJK_Compatibility_Ideographs
120 {65072, 65103}, // CJK_Compatibility_Forms
121 {65381, 65500}, // Katakana_Hangul_Halfwidth
122 {131072, 196607}// Supplementary_Ideographic_Plane
123 }};
124 for (auto range : ranges) {
125 if (range.first <= unichar && range.second > unichar) {
126 return true;
127 }
128 }
129 return false;
130}
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
int32_t SkUnichar
Definition: SkTypes.h:175
int find(T *array, int N, T item)
bool isRegionalIndicator(SkUnichar utf8) override
bool isTabulation(SkUnichar utf8) override
bool isEmojiModifierBase(SkUnichar utf8) override
bool isIdeographic(SkUnichar utf8) override
bool isEmojiModifier(SkUnichar utf8) override
bool isEmoji(SkUnichar utf8) override
bool isSpace(SkUnichar utf8) override
bool isHardBreak(SkUnichar utf8) override
bool isControl(SkUnichar utf8) override
bool isWhitespace(SkUnichar utf8) override
bool isEmojiComponent(SkUnichar utf8) override