Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: Source/platform/fonts/Character.cpp

Issue 1206883002: Fix default text orientation that do not conform Unicode Technical Report #50 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/platform/fonts/Character.h ('k') | Source/platform/fonts/Font.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 // Search for other Complex cases 160 // Search for other Complex cases
161 if (valueInIntervalList(complexCodePathRanges, c)) 161 if (valueInIntervalList(complexCodePathRanges, c))
162 return ComplexPath; 162 return ComplexPath;
163 } 163 }
164 164
165 return result; 165 return result;
166 } 166 }
167 167
168 bool Character::shouldIgnoreRotation(UChar32 character) 168 bool Character::isUprightInMixedVertical(UChar32 character)
169 { 169 {
170 // Fast path for common non-CJK
171 if (character < 0x000A7)
172 return false;
173
174 // Fast path for common CJK
175 if (isInRange(character, 0x02E80, 0x0A4CF))
176 return true;
177
178 if (isInRange(character, 0x0FF01, 0x0FFE7)) {
179 if (character <= 0x0FF0C || isInRange(character, 0x0FF0E, 0x0FF1B)
180 || isInRange(character, 0x0FF1F, 0x0FF60) || character >= 0x0FFE0)
181 return true;
182 return false;
183 }
184
185 // Fast path for medium-common non-CJK
170 if (character == 0x000A7 || character == 0x000A9 || character == 0x000AE) 186 if (character == 0x000A7 || character == 0x000A9 || character == 0x000AE)
171 return true; 187 return true;
188 if (character == 0x000B1 || character == 0x000BC || character == 0x000BD || character == 0x000BE)
189 return true;
190 if (character == 0x000D7 || character == 0x000F7)
191 return true;
192 if (character < 0x002EA)
193 return false;
172 194
173 if (character == 0x000B6 || character == 0x000BC || character == 0x000BD || character == 0x000BE) 195 static const UChar32 uprightRanges[] = {
174 return true; 196 // Spacing Modifier Letters (Part of)
175 197 0x002EA, 0x002EB,
176 if (isInRange(character, 0x002E5, 0x002EB)) 198 // Hangul Jamo
177 return true; 199 0x01100, 0x011FF,
178 200 // Unified Canadian Aboriginal Syllabics
179 if (isInRange(character, 0x01100, 0x011FF) || isInRange(character, 0x01401, 0x0167F) || isInRange(character, 0x018B0, 0x018FF)) 201 0x01401, 0x0167F,
180 return true; 202 // Unified Canadian Aboriginal Syllabics Extended
181 203 0x018B0, 0x018FF,
182 if (character == 0x02016 || character == 0x02018 || character == 0x02019 || character == 0x02020 || character == 0x02021 204 // General Punctuation (Part of)
183 || character == 0x2030 || character == 0x02031) 205 0x02016, 0x02016,
184 return true; 206 0x02020, 0x02021,
185 207 0x02030, 0x02031,
186 if (isInRange(character, 0x0203B, 0x0203D) || character == 0x02042 || charac ter == 0x02044 || character == 0x02047 208 0x0203B, 0x0203C,
187 || character == 0x02048 || character == 0x02049 || character == 0x2051) 209 0x02042, 0x02042,
188 return true; 210 0x02047, 0x02049,
189 211 0x02051, 0x02051,
190 if (isInRange(character, 0x02065, 0x02069) || isInRange(character, 0x020DD, 0x020E0) 212 0x02065, 0x02069,
191 || isInRange(character, 0x020E2, 0x020E4) || isInRange(character, 0x0210 0, 0x02117) 213 // Combining Diacritical Marks for Symbols (Part of)
192 || isInRange(character, 0x02119, 0x02131) || isInRange(character, 0x0213 3, 0x0213F)) 214 0x020DD, 0x020E0,
193 return true; 215 0x020E2, 0x020E4,
194 216 // Letterlike Symbols (Part of)/Number Forms
195 if (isInRange(character, 0x02145, 0x0214A) || character == 0x0214C || charac ter == 0x0214D 217 0x02100, 0x02101,
196 || isInRange(character, 0x0214F, 0x0218F)) 218 0x02103, 0x02109,
197 return true; 219 0x0210F, 0x0210F,
198 220 0x02113, 0x02114,
199 if (isInRange(character, 0x02300, 0x02307) || isInRange(character, 0x0230C, 0x0231F) 221 0x02116, 0x02117,
200 || isInRange(character, 0x02322, 0x0232B) || isInRange(character, 0x0237 D, 0x0239A) 222 0x0211E, 0x02123,
201 || isInRange(character, 0x023B4, 0x023B6) || isInRange(character, 0x023B A, 0x023CF) 223 0x02125, 0x02125,
202 || isInRange(character, 0x023D1, 0x023DB) || isInRange(character, 0x023E 2, 0x024FF)) 224 0x02127, 0x02127,
203 return true; 225 0x02129, 0x02129,
204 226 0x0212E, 0x0212E,
205 if (isInRange(character, 0x025A0, 0x02619) || isInRange(character, 0x02620, 0x02767) 227 0x02135, 0x0213F,
206 || isInRange(character, 0x02776, 0x02793) || isInRange(character, 0x02B1 2, 0x02B2F) 228 0x02145, 0x0214A,
207 || isInRange(character, 0x02B4D, 0x02BFF) || isInRange(character, 0x02E8 0, 0x03007)) 229 0x0214C, 0x0214D,
208 return true; 230 0x0214F, 0x0218F,
209 231 // Mathematical Operators (Part of)
210 if (character == 0x03012 || character == 0x03013 || isInRange(character, 0x0 3020, 0x0302F) 232 0x0221E, 0x0221E,
211 || isInRange(character, 0x03031, 0x0309F) || isInRange(character, 0x030A 1, 0x030FB) 233 0x02234, 0x02235,
212 || isInRange(character, 0x030FD, 0x0A4CF)) 234 // Miscellaneous Technical (Part of)
213 return true; 235 0x02300, 0x02307,
214 236 0x0230C, 0x0231F,
215 if (isInRange(character, 0x0A960, 0x0A97F) 237 0x02324, 0x0232B,
216 || isInRange(character, 0x0AC00, 0x0D7FF) || isInRange(character, 0x0E00 0, 0x0FAFF)) 238 0x0237D, 0x0239A,
217 return true; 239 0x023BE, 0x023CD,
218 240 0x023CF, 0x023CF,
219 if (isInRange(character, 0x0FE10, 0x0FE1F) || isInRange(character, 0x0FE30, 0x0FE48) 241 0x023D1, 0x023DB,
220 || isInRange(character, 0x0FE50, 0x0FE57) || isInRange(character, 0x0FE5 F, 0x0FE62) 242 0x023E2, 0x02422,
221 || isInRange(character, 0x0FE67, 0x0FE6F)) 243 // Control Pictures (Part of)/Optical Character Recognition/Enclosed Alp hanumerics
222 return true; 244 0x02424, 0x024FF,
223 245 // Geometric Shapes/Miscellaneous Symbols (Part of)
224 if (isInRange(character, 0x0FF01, 0x0FF07) || isInRange(character, 0x0FF0A, 0x0FF0C) 246 0x025A0, 0x02619,
225 || isInRange(character, 0x0FF0E, 0x0FF19) || isInRange(character, 0x0FF1 F, 0x0FF3A)) 247 0x02620, 0x02767,
226 return true; 248 0x02776, 0x02793,
227 249 // Miscellaneous Symbols and Arrows (Part of)
228 if (character == 0x0FF3C || character == 0x0FF3E) 250 0x02B12, 0x02B2F,
229 return true; 251 0x02B50, 0x02B59,
230 252 0x02BB8, 0x02BFF,
231 if (isInRange(character, 0x0FF40, 0x0FF5A) || isInRange(character, 0x0FFE0, 0x0FFE2) 253 // Hangul Jamo Extended-A
232 || isInRange(character, 0x0FFE4, 0x0FFE7) || isInRange(character, 0x0FFF 0, 0x0FFF8) 254 0x0A960, 0x0A97F,
233 || character == 0x0FFFD) 255 // Hangul Syllables/Hangul Jamo Extended-B
234 return true; 256 0x0AC00, 0x0D7FF,
235 257 // Private Use Area/CJK Compatibility Ideographs
236 if (isInRange(character, 0x13000, 0x1342F) || isInRange(character, 0x1B000, 0x1B0FF) 258 0x0E000, 0x0FAFF,
237 || isInRange(character, 0x1D000, 0x1D1FF) || isInRange(character, 0x1D30 0, 0x1D37F) 259 // Vertical Forms
238 || isInRange(character, 0x1F000, 0x1F64F) || isInRange(character, 0x1F68 0, 0x1F77F)) 260 0x0FE10, 0x0FE1F,
239 return true; 261 // CJK Compatibility Forms (Part of)
240 262 0x0FE30, 0x0FE48,
241 if (isInRange(character, 0x20000, 0x2FFFD) || isInRange(character, 0x30000, 0x3FFFD)) 263 // Small Form Variants (Part of)
242 return true; 264 0x0FE50, 0x0FE57,
243 265 0x0FE59, 0x0FE62,
244 return false; 266 0x0FE67, 0x0FE6F,
267 // Specials (Part of)
268 0x0FFF0, 0x0FFF8,
269 0x0FFFC, 0x0FFFD,
270 // Meroitic Hieroglyphs
271 0x10980, 0x1099F,
272 // Siddham
273 0x11580, 0x115FF,
274 // Egyptian Hieroglyphs
275 0x13000, 0x1342F,
276 // Kana Supplement
277 0x1B000, 0x1B0FF,
278 // Byzantine Musical Symbols/Musical Symbols
279 0x1D000, 0x1D1FF,
280 // Tai Xuan Jing Symbols/Counting Rod Numerals
281 0x1D300, 0x1D37F,
282 // Mahjong Tiles/Domino Tiles/Playing Cards/Enclosed Alphanumeric Supple ment
283 // Enclosed Ideographic Supplement/Enclosed Ideographic Supplement
284 // Emoticons/Ornamental Dingbats/Transport and Map Symbols/Alchemical Sy mbols
285 // Alchemical Symbols
286 0x1F000, 0x1F7FF,
287 // CJK Unified Ideographs Extension B/C/D
288 // CJK Compatibility Ideographs Supplement
289 0x20000, 0x2FFFD,
290 0x30000, 0x3FFFD,
291 // Supplementary Private Use Area-A
292 0xF0000, 0xFFFFD,
293 // Supplementary Private Use Area-B
294 0x100000, 0x10FFFD,
295 };
296 return valueInIntervalList(uprightRanges, character);
245 } 297 }
246 298
247 bool Character::isCJKIdeograph(UChar32 c) 299 bool Character::isCJKIdeograph(UChar32 c)
248 { 300 {
249 static const UChar32 cjkIdeographRanges[] = { 301 static const UChar32 cjkIdeographRanges[] = {
250 // CJK Radicals Supplement and Kangxi Radicals. 302 // CJK Radicals Supplement and Kangxi Radicals.
251 0x2E80, 0x2FDF, 303 0x2E80, 0x2FDF,
252 // CJK Strokes. 304 // CJK Strokes.
253 0x31C0, 0x31EF, 305 0x31C0, 0x31EF,
254 // CJK Unified Ideographs Extension A. 306 // CJK Unified Ideographs Extension A.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 { 496 {
445 return normalizeSpacesInternal(characters, length); 497 return normalizeSpacesInternal(characters, length);
446 } 498 }
447 499
448 String Character::normalizeSpaces(const UChar* characters, unsigned length) 500 String Character::normalizeSpaces(const UChar* characters, unsigned length)
449 { 501 {
450 return normalizeSpacesInternal(characters, length); 502 return normalizeSpacesInternal(characters, length);
451 } 503 }
452 504
453 } // namespace blink 505 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/Character.h ('k') | Source/platform/fonts/Font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698