| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 Google Inc. All rights reserved. | 2 * Copyright (c) 2010 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 // normalization (e.g., Arabic text). Unless the run contains the diacritica
l marks, | 360 // normalization (e.g., Arabic text). Unless the run contains the diacritica
l marks, |
| 361 // Harfbuzz will do the same thing for us using the GSUB table. | 361 // Harfbuzz will do the same thing for us using the GSUB table. |
| 362 // 2) Convert spacing characters into plain spaces, as some fonts will provi
de glyphs | 362 // 2) Convert spacing characters into plain spaces, as some fonts will provi
de glyphs |
| 363 // for characters like '\n' otherwise. | 363 // for characters like '\n' otherwise. |
| 364 // 3) Convert mirrored characters such as parenthesis for rtl text. | 364 // 3) Convert mirrored characters such as parenthesis for rtl text. |
| 365 | 365 |
| 366 // Convert to NFC form if the text has diacritical marks. | 366 // Convert to NFC form if the text has diacritical marks. |
| 367 icu::UnicodeString normalizedString; | 367 icu::UnicodeString normalizedString; |
| 368 UErrorCode error = U_ZERO_ERROR; | 368 UErrorCode error = U_ZERO_ERROR; |
| 369 | 369 |
| 370 for (int16_t i = 0; i < originalRun.length(); ++i) { | 370 for (int i = 0; i < originalRun.length(); ++i) { |
| 371 UChar ch = originalRun[i]; | 371 UChar ch = originalRun[i]; |
| 372 if (::ublock_getCode(ch) == UBLOCK_COMBINING_DIACRITICAL_MARKS) { | 372 if (::ublock_getCode(ch) == UBLOCK_COMBINING_DIACRITICAL_MARKS) { |
| 373 icu::Normalizer::normalize(icu::UnicodeString(originalRun.characters
(), | 373 icu::Normalizer::normalize(icu::UnicodeString(originalRun.characters
(), |
| 374 originalRun.length()), UNORM_NFC, 0 /* no
options */, | 374 originalRun.length()), UNORM_NFC, 0 /* no
options */, |
| 375 normalizedString, error); | 375 normalizedString, error); |
| 376 if (U_FAILURE(error)) | 376 if (U_FAILURE(error)) |
| 377 return originalRun; | 377 return originalRun; |
| 378 break; | 378 break; |
| 379 } | 379 } |
| 380 } | 380 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 393 normalizedBuffer = adoptArrayPtr(new UChar[normalizedBufferLength + 1]); | 393 normalizedBuffer = adoptArrayPtr(new UChar[normalizedBufferLength + 1]); |
| 394 | 394 |
| 395 normalizeSpacesAndMirrorChars(sourceText, originalRun.rtl(), normalizedBuffe
r.get(), normalizedBufferLength); | 395 normalizeSpacesAndMirrorChars(sourceText, originalRun.rtl(), normalizedBuffe
r.get(), normalizedBufferLength); |
| 396 | 396 |
| 397 normalizedRun = adoptPtr(new TextRun(originalRun)); | 397 normalizedRun = adoptPtr(new TextRun(originalRun)); |
| 398 normalizedRun->setText(normalizedBuffer.get(), normalizedBufferLength); | 398 normalizedRun->setText(normalizedBuffer.get(), normalizedBufferLength); |
| 399 return *normalizedRun; | 399 return *normalizedRun; |
| 400 } | 400 } |
| 401 | 401 |
| 402 } // namespace WebCore | 402 } // namespace WebCore |
| OLD | NEW |