OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // Takes a flattened list of closed intervals | 101 // Takes a flattened list of closed intervals |
102 template <class T, size_t size> | 102 template <class T, size_t size> |
103 bool valueInIntervalList(const T (&intervalList)[size], const T& value) { | 103 bool valueInIntervalList(const T (&intervalList)[size], const T& value) { |
104 const T* bound = | 104 const T* bound = |
105 std::upper_bound(&intervalList[0], &intervalList[size], value); | 105 std::upper_bound(&intervalList[0], &intervalList[size], value); |
106 if ((bound - intervalList) % 2 == 1) | 106 if ((bound - intervalList) % 2 == 1) |
107 return true; | 107 return true; |
108 return bound > intervalList && *(bound - 1) == value; | 108 return bound > intervalList && *(bound - 1) == value; |
109 } | 109 } |
110 | 110 |
111 CodePath Character::characterRangeCodePath(const UChar* characters, | |
112 unsigned len) { | |
113 static const UChar complexCodePathRanges[] = { | |
114 // U+02E5 through U+02E9 (Modifier Letters : Tone letters) | |
115 0x2E5, 0x2E9, | |
116 // U+0300 through U+036F Combining diacritical marks | |
117 0x300, 0x36F, | |
118 // U+0591 through U+05CF excluding U+05BE Hebrew combining marks, ... | |
119 0x0591, 0x05BD, | |
120 // ... Hebrew punctuation Paseq, Sof Pasuq and Nun Hafukha | |
121 0x05BF, 0x05CF, | |
122 // U+0600 through U+109F Arabic, Syriac, Thaana, NKo, Samaritan, Mandaic, | |
123 // Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu, Kannada, | |
124 // Malayalam, Sinhala, Thai, Lao, Tibetan, Myanmar | |
125 0x0600, 0x109F, | |
126 // U+1100 through U+11FF Hangul Jamo (only Ancient Korean should be left | |
127 // here if you precompose; Modern Korean will be precomposed as a result | |
128 // of step A) | |
129 0x1100, 0x11FF, | |
130 // U+135D through U+135F Ethiopic combining marks | |
131 0x135D, 0x135F, | |
132 // U+1780 through U+18AF Tagalog, Hanunoo, Buhid, Taghanwa, Khmer, | |
133 // Mongolian | |
134 0x1700, 0x18AF, | |
135 // U+1900 through U+194F Limbu (Unicode 4.0) | |
136 0x1900, 0x194F, | |
137 // U+1980 through U+19DF New Tai Lue | |
138 0x1980, 0x19DF, | |
139 // U+1A00 through U+1CFF Buginese, Tai Tham, Balinese, Batak, Lepcha, | |
140 // Vedic | |
141 0x1A00, 0x1CFF, | |
142 // U+1DC0 through U+1DFF Comining diacritical mark supplement | |
143 0x1DC0, 0x1DFF, | |
144 // U+20D0 through U+20FF Combining marks for symbols | |
145 0x20D0, 0x20FF, | |
146 // U+2CEF through U+2CF1 Combining marks for Coptic | |
147 0x2CEF, 0x2CF1, | |
148 // U+302A through U+302F Ideographic and Hangul Tone marks | |
149 0x302A, 0x302F, | |
150 // Combining Katakana-Hiragana Voiced/Semi-voiced Sound Mark | |
151 0x3099, 0x309A, | |
152 // U+A67C through U+A67D Combining marks for old Cyrillic | |
153 0xA67C, 0xA67D, | |
154 // U+A6F0 through U+A6F1 Combining mark for Bamum | |
155 0xA6F0, 0xA6F1, | |
156 // U+A800 through U+ABFF Nagri, Phags-pa, Saurashtra, Devanagari Extended, | |
157 // Hangul Jamo Ext. A, Javanese, Myanmar Extended A, Tai Viet, | |
158 // Meetei Mayek | |
159 0xA800, 0xABFF, | |
160 // U+D7B0 through U+D7FF Hangul Jamo Ext. B | |
161 0xD7B0, 0xD7FF, | |
162 // U+E000..U+F8FF BMP Private Use Area | |
163 0xE000, 0xF8FF, | |
164 // U+FE00 through U+FE0F Unicode variation selectors | |
165 0xFE00, 0xFE0F, | |
166 // U+FE20 through U+FE2F Combining half marks | |
167 0xFE20, 0xFE2F}; | |
168 | |
169 CodePath result = SimplePath; | |
170 for (unsigned i = 0; i < len; i++) { | |
171 const UChar c = characters[i]; | |
172 | |
173 // Shortcut for common case | |
174 if (c < 0x2E5) | |
175 continue; | |
176 | |
177 // Surrogate pairs | |
178 if (c > 0xD7FF && c <= 0xDBFF) { | |
179 if (i == len - 1) | |
180 continue; | |
181 | |
182 UChar next = characters[++i]; | |
183 if (!U16_IS_TRAIL(next)) | |
184 continue; | |
185 | |
186 UChar32 supplementaryCharacter = U16_GET_SUPPLEMENTARY(c, next); | |
187 | |
188 if (supplementaryCharacter < | |
189 0x1F1E6) // U+1F1E6 through U+1F1FF Regional Indicator Symbols | |
190 continue; | |
191 if (supplementaryCharacter <= 0x1F1FF) | |
192 return ComplexPath; | |
193 | |
194 // Emoji Fitzpatrick modifiers trigger upgrade to complex path for shaping | |
195 // them. | |
196 if (supplementaryCharacter < 0x1F3FB) | |
197 continue; | |
198 if (supplementaryCharacter <= 0x1F3FF) | |
199 return ComplexPath; | |
200 | |
201 if (supplementaryCharacter == eyeCharacter) | |
202 return ComplexPath; | |
203 | |
204 // Man and Woman Emojies, in order to support emoji joiner combinations | |
205 // for family and couple pictographs. | |
206 // Compare http://unicode.org/reports/tr51/#Emoji_ZWJ_Sequences | |
207 if (supplementaryCharacter < 0x1F468) | |
208 continue; | |
209 if (supplementaryCharacter <= 0x1F469) | |
210 return ComplexPath; | |
211 | |
212 if (supplementaryCharacter == leftSpeechBubbleCharacter) | |
213 return ComplexPath; | |
214 | |
215 if (supplementaryCharacter < | |
216 0xE0100) // U+E0100 through U+E01EF Unicode variation selectors. | |
217 continue; | |
218 if (supplementaryCharacter <= 0xE01EF) | |
219 return ComplexPath; | |
220 | |
221 // Supplemental Private Use Area-A | |
222 if (supplementaryCharacter < 0xF0000) | |
223 continue; | |
224 if (supplementaryCharacter <= 0xFFFFD) | |
225 return ComplexPath; | |
226 | |
227 // Supplemental Private Use Area-B | |
228 if (supplementaryCharacter < 0x100000) | |
229 continue; | |
230 if (supplementaryCharacter <= 0x10FFFD) | |
231 return ComplexPath; | |
232 | |
233 // FIXME: Check for Brahmi (U+11000 block), Kaithi (U+11080 block) and | |
234 // other complex scripts in plane 1 or higher. | |
235 | |
236 continue; | |
237 } | |
238 | |
239 // Search for other Complex cases | |
240 if (valueInIntervalList(complexCodePathRanges, c)) | |
241 return ComplexPath; | |
242 } | |
243 | |
244 return result; | |
245 } | |
246 | |
247 bool Character::isUprightInMixedVertical(UChar32 character) { | 111 bool Character::isUprightInMixedVertical(UChar32 character) { |
248 RETURN_HAS_PROPERTY(character, isUprightInMixedVertical) | 112 RETURN_HAS_PROPERTY(character, isUprightInMixedVertical) |
249 } | 113 } |
250 | 114 |
251 bool Character::isCJKIdeographOrSymbol(UChar32 c) { | 115 bool Character::isCJKIdeographOrSymbol(UChar32 c) { |
252 // Likely common case | 116 // Likely common case |
253 if (c < 0x2C7) | 117 if (c < 0x2C7) |
254 return false; | 118 return false; |
255 | 119 |
256 RETURN_HAS_PROPERTY(c, isCJKIdeographOrSymbol) | 120 RETURN_HAS_PROPERTY(c, isCJKIdeographOrSymbol) |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 } | 253 } |
390 | 254 |
391 bool Character::isCommonOrInheritedScript(UChar32 character) { | 255 bool Character::isCommonOrInheritedScript(UChar32 character) { |
392 UErrorCode status = U_ZERO_ERROR; | 256 UErrorCode status = U_ZERO_ERROR; |
393 UScriptCode script = uscript_getScript(character, &status); | 257 UScriptCode script = uscript_getScript(character, &status); |
394 return U_SUCCESS(status) && | 258 return U_SUCCESS(status) && |
395 (script == USCRIPT_COMMON || script == USCRIPT_INHERITED); | 259 (script == USCRIPT_COMMON || script == USCRIPT_INHERITED); |
396 } | 260 } |
397 | 261 |
398 } // namespace blink | 262 } // namespace blink |
OLD | NEW |