457 {
459 if (fNameTableSize < sizeof(nameTable)) {
460 return false;
461 }
462 memcpy(&nameTable, fNameTable, sizeof(nameTable));
463
464 const uint8_t* nameRecords = fNameTable + sizeof(nameTable);
465 const size_t nameRecordsSize = fNameTableSize - sizeof(nameTable);
466
468 if (fNameTableSize < stringTableOffset) {
469 return false;
470 }
471 const uint8_t* stringTable = fNameTable + stringTableOffset;
472 const size_t stringTableSize = fNameTableSize - stringTableOffset;
473
474
477 const size_t nameRecordsMax =
std::min(nameRecordsCount, nameRecordsSize /
sizeof(nameRecord));
478 do {
479 if (fIndex >= nameRecordsMax) {
480 return false;
481 }
482
483 memcpy(&nameRecord, nameRecords + sizeof(nameRecord)*fIndex, sizeof(nameRecord));
484 ++fIndex;
486
488
489
492 if (stringTableSize <
nameOffset + nameLength) {
493 return false;
494 }
495 const uint8_t* nameString = stringTable +
nameOffset;
504 {
505 record.name.reset();
506 break;
507 }
508 [[fallthrough]];
512 break;
513
515
518 {
519 record.name.reset();
520 break;
521 }
523 break;
524
526
527 default:
529 record.name.reset();
530 break;
531 }
532
533
535
536
538 const uint16_t languageTagRecordIndex = languageID - 0x8000;
539
540 if (nameRecordsSize < sizeof(nameRecord)*nameRecordsCount) {
541 return false;
542 }
543 const uint8_t* format1extData = nameRecords + sizeof(nameRecord)*nameRecordsCount;
544 size_t format1extSize = nameRecordsSize - sizeof(nameRecord)*nameRecordsCount;
546 if (format1extSize < sizeof(format1ext)) {
547 return false;
548 }
549 memcpy(&format1ext, format1extData, sizeof(format1ext));
550
551 const uint8_t* languageTagRecords = format1extData + sizeof(format1ext);
552 size_t languageTagRecordsSize = format1extSize - sizeof(format1ext);
555 if (languageTagRecordsSize < sizeof(languageTagRecord)*(languageTagRecordIndex+1)) {
556 return false;
557 }
558 const uint8_t* languageTagData = languageTagRecords
559 + sizeof(languageTagRecord)*languageTagRecordIndex;
560 memcpy(&languageTagRecord, languageTagData, sizeof(languageTagRecord));
561
564
565 if (fNameTableSize < stringTableOffset + languageOffset + languageLength) {
566 return false;
567 }
568 const uint8_t* languageString = stringTable + languageOffset;
570 return true;
571 }
572 }
573
574
576 int languageIndex = SkTSearch<BCP47FromLanguageId, BCP47FromLanguageIdLess>(
578 if (languageIndex >= 0) {
580 return true;
581 }
582
583
584 record.language = "und";
585 return true;
586}
#define SkEndian_SwapBE16(n)
static const struct BCP47FromLanguageId BCP47FromLanguageID[]
static void SkStringFromMacRoman(const uint8_t *macRoman, size_t length, SkString &utf8)
static void SkString_from_UTF16BE(const uint8_t *utf16be, size_t length, SkString &utf8)
static float min(float r, float g, float b)
enum SkOTTableName::Record::EncodingID::Macintosh::Value value
enum SkOTTableName::Record::EncodingID::Windows::Value value
struct SkOTTableName::Record::PlatformID platformID
union SkOTTableName::Record::NameID nameID
union SkOTTableName::Record::LanguageID languageID
union SkOTTableName::Record::EncodingID encodingID
SK_OT_USHORT stringOffset
static const SK_OT_USHORT format_1
struct SkOTTableName::Record::EncodingID::Windows windows
struct SkOTTableName::Record::EncodingID::Macintosh macintosh
SK_OT_USHORT languageTagID
SK_OT_USHORT fontSpecific