/* static */ uint64_t SFNTData::GetUniqueKey(const uint8_t *aFontData, uint32_t aDataLength) { uint64_t hash; UniquePtr<SFNTData> sfntData = SFNTData::Create(aFontData, aDataLength); mozilla::u16string firstName; if (sfntData && sfntData->GetU16FullName(0, firstName)) { hash = HashString(firstName.c_str(), firstName.length()); } else { gfxWarning() << "Failed to get name from font data hashing whole font."; hash = HashString(aFontData, aDataLength); } return hash << 32 | aDataLength;; }
bool GetU16FullName(mozilla::u16string& aU16FullName) { const TableDirEntry* dirEntry = GetDirEntry(TRUETYPE_TAG('n', 'a', 'm', 'e')); if (!dirEntry) { gfxWarning() << "Name table entry not found."; return false; } UniquePtr<SFNTNameTable> nameTable = SFNTNameTable::Create((mFontData + dirEntry->offset), dirEntry->length); if (!nameTable) { return false; } return nameTable->GetU16FullName(aU16FullName); }