| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkOTTable_name.h" | 8 #include "SkOTTable_name.h" |
| 9 | 9 |
| 10 #include "SkEndian.h" | 10 #include "SkEndian.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 { 0x4409, "en-MY" }, //English | 424 { 0x4409, "en-MY" }, //English |
| 425 { 0x440a, "es-SV" }, //Spanish | 425 { 0x440a, "es-SV" }, //Spanish |
| 426 { 0x4809, "en-SG" }, //English | 426 { 0x4809, "en-SG" }, //English |
| 427 { 0x480a, "es-HN" }, //Spanish | 427 { 0x480a, "es-HN" }, //Spanish |
| 428 { 0x4c0a, "es-NI" }, //Spanish | 428 { 0x4c0a, "es-NI" }, //Spanish |
| 429 { 0x500a, "es-PR" }, //Spanish | 429 { 0x500a, "es-PR" }, //Spanish |
| 430 { 0x540a, "es-US" }, //Spanish | 430 { 0x540a, "es-US" }, //Spanish |
| 431 }; | 431 }; |
| 432 | 432 |
| 433 namespace { | 433 namespace { |
| 434 int BCP47FromLanguageIdCompare(const BCP47FromLanguageId* a, const BCP47FromLang
uageId* b) { | 434 bool BCP47FromLanguageIdLess(const BCP47FromLanguageId& a, const BCP47FromLangua
geId& b) { |
| 435 return a->languageID - b->languageID; | 435 return a.languageID < b.languageID; |
| 436 } | 436 } |
| 437 } | 437 } |
| 438 | 438 |
| 439 bool SkOTTableName::Iterator::next(SkOTTableName::Iterator::Record& record) { | 439 bool SkOTTableName::Iterator::next(SkOTTableName::Iterator::Record& record) { |
| 440 const size_t nameRecordsCount = SkEndian_SwapBE16(fName.count); | 440 const size_t nameRecordsCount = SkEndian_SwapBE16(fName.count); |
| 441 const SkOTTableName::Record* nameRecords = SkTAfter<const SkOTTableName::Rec
ord>(&fName); | 441 const SkOTTableName::Record* nameRecords = SkTAfter<const SkOTTableName::Rec
ord>(&fName); |
| 442 const SkOTTableName::Record* nameRecord; | 442 const SkOTTableName::Record* nameRecord; |
| 443 | 443 |
| 444 // Find the next record which matches the requested type. | 444 // Find the next record which matches the requested type. |
| 445 do { | 445 do { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 uint16_t offset = SkEndian_SwapBE16(languageTagRecord[languageTagRec
ordIndex].offset); | 502 uint16_t offset = SkEndian_SwapBE16(languageTagRecord[languageTagRec
ordIndex].offset); |
| 503 uint16_t length = SkEndian_SwapBE16(languageTagRecord[languageTagRec
ordIndex].length); | 503 uint16_t length = SkEndian_SwapBE16(languageTagRecord[languageTagRec
ordIndex].length); |
| 504 const uint16_t* string = SkTAddOffset<const uint16_t>(stringTable, o
ffset); | 504 const uint16_t* string = SkTAddOffset<const uint16_t>(stringTable, o
ffset); |
| 505 SkStringFromUTF16BE(string, length, record.language); | 505 SkStringFromUTF16BE(string, length, record.language); |
| 506 return true; | 506 return true; |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 | 509 |
| 510 // Handle format 0 languages, translating them into BCP 47. | 510 // Handle format 0 languages, translating them into BCP 47. |
| 511 const BCP47FromLanguageId target = { languageID, "" }; | 511 const BCP47FromLanguageId target = { languageID, "" }; |
| 512 int languageIndex = SkTSearch<BCP47FromLanguageId, BCP47FromLanguageIdCompar
e>( | 512 int languageIndex = SkTSearch<BCP47FromLanguageId, BCP47FromLanguageIdLess>( |
| 513 BCP47FromLanguageID, SK_ARRAY_COUNT(BCP47FromLanguageID), target, sizeof
(target)); | 513 BCP47FromLanguageID, SK_ARRAY_COUNT(BCP47FromLanguageID), target, sizeof
(target)); |
| 514 if (languageIndex >= 0) { | 514 if (languageIndex >= 0) { |
| 515 record.language = BCP47FromLanguageID[languageIndex].bcp47; | 515 record.language = BCP47FromLanguageID[languageIndex].bcp47; |
| 516 return true; | 516 return true; |
| 517 } | 517 } |
| 518 | 518 |
| 519 // Unknown language, return the BCP 47 code 'und' for 'undetermined'. | 519 // Unknown language, return the BCP 47 code 'und' for 'undetermined'. |
| 520 SkASSERT(false); | 520 SkASSERT(false); |
| 521 record.language = "und"; | 521 record.language = "und"; |
| 522 return true; | 522 return true; |
| 523 } | 523 } |
| OLD | NEW |