OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkData.h" | 8 #include "SkData.h" |
9 #include "SkEndian.h" | 9 #include "SkEndian.h" |
10 #include "SkSFNTHeader.h" | 10 #include "SkSFNTHeader.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return NULL; | 96 return NULL; |
97 } | 97 } |
98 | 98 |
99 //Fix up the offsets of the directory entries after the old 'name' table ent
ry. | 99 //Fix up the offsets of the directory entries after the old 'name' table ent
ry. |
100 SkSFNTHeader::TableDirectoryEntry* currentEntry = reinterpret_cast<SkSFNTHea
der::TableDirectoryEntry*>(data + sizeof(SkSFNTHeader)); | 100 SkSFNTHeader::TableDirectoryEntry* currentEntry = reinterpret_cast<SkSFNTHea
der::TableDirectoryEntry*>(data + sizeof(SkSFNTHeader)); |
101 SkSFNTHeader::TableDirectoryEntry* endEntry = currentEntry + numTables; | 101 SkSFNTHeader::TableDirectoryEntry* endEntry = currentEntry + numTables; |
102 SkSFNTHeader::TableDirectoryEntry* headTableEntry = NULL; | 102 SkSFNTHeader::TableDirectoryEntry* headTableEntry = NULL; |
103 for (; currentEntry < endEntry; ++currentEntry) { | 103 for (; currentEntry < endEntry; ++currentEntry) { |
104 uint32_t oldOffset = SkEndian_SwapBE32(currentEntry->offset); | 104 uint32_t oldOffset = SkEndian_SwapBE32(currentEntry->offset); |
105 if (oldOffset > oldNameTableOffset) { | 105 if (oldOffset > oldNameTableOffset) { |
106 currentEntry->offset = SkEndian_SwapBE32(oldOffset - oldNameTablePhy
sicalSize); | 106 currentEntry->offset = SkEndian_SwapBE32(SkToU32(oldOffset - oldName
TablePhysicalSize)); |
107 } | 107 } |
108 if (SkOTTableHead::TAG == currentEntry->tag) { | 108 if (SkOTTableHead::TAG == currentEntry->tag) { |
109 headTableEntry = currentEntry; | 109 headTableEntry = currentEntry; |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 // Make the table directory entry point to the new 'name' table. | 113 // Make the table directory entry point to the new 'name' table. |
114 SkSFNTHeader::TableDirectoryEntry* nameTableEntry = reinterpret_cast<SkSFNTH
eader::TableDirectoryEntry*>(data + sizeof(SkSFNTHeader)) + tableIndex; | 114 SkSFNTHeader::TableDirectoryEntry* nameTableEntry = reinterpret_cast<SkSFNTH
eader::TableDirectoryEntry*>(data + sizeof(SkSFNTHeader)) + tableIndex; |
115 nameTableEntry->logicalLength = SkEndian_SwapBE32(nameTableLogicalSize); | 115 nameTableEntry->logicalLength = SkEndian_SwapBE32(SkToU32(nameTableLogicalSi
ze)); |
116 nameTableEntry->offset = SkEndian_SwapBE32(originalDataSize); | 116 nameTableEntry->offset = SkEndian_SwapBE32(SkToU32(originalDataSize)); |
117 | 117 |
118 // Write the new 'name' table after the original font data. | 118 // Write the new 'name' table after the original font data. |
119 SkOTTableName* nameTable = reinterpret_cast<SkOTTableName*>(data + originalD
ataSize); | 119 SkOTTableName* nameTable = reinterpret_cast<SkOTTableName*>(data + originalD
ataSize); |
120 unsigned short stringOffset = sizeof(SkOTTableName) + (namesCount * sizeof(S
kOTTableName::Record)); | 120 unsigned short stringOffset = sizeof(SkOTTableName) + (namesCount * sizeof(S
kOTTableName::Record)); |
121 nameTable->format = SkOTTableName::format_0; | 121 nameTable->format = SkOTTableName::format_0; |
122 nameTable->count = SkEndian_SwapBE16(namesCount); | 122 nameTable->count = SkEndian_SwapBE16(namesCount); |
123 nameTable->stringOffset = SkEndian_SwapBE16(stringOffset); | 123 nameTable->stringOffset = SkEndian_SwapBE16(stringOffset); |
124 | 124 |
125 SkOTTableName::Record* nameRecords = reinterpret_cast<SkOTTableName::Record*
>(data + originalDataSize + sizeof(SkOTTableName)); | 125 SkOTTableName::Record* nameRecords = reinterpret_cast<SkOTTableName::Record*
>(data + originalDataSize + sizeof(SkOTTableName)); |
126 for (int i = 0; i < namesCount; ++i) { | 126 for (int i = 0; i < namesCount; ++i) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 fFamilyNameIter.reset(fTypes[fTypesIndex]); | 194 fFamilyNameIter.reset(fTypes[fTypesIndex]); |
195 } while (true); | 195 } while (true); |
196 } | 196 } |
197 | 197 |
198 SkOTTableName::Record::NameID::Predefined::Value | 198 SkOTTableName::Record::NameID::Predefined::Value |
199 SkOTUtils::LocalizedStrings_NameTable::familyNameTypes[3] = { | 199 SkOTUtils::LocalizedStrings_NameTable::familyNameTypes[3] = { |
200 SkOTTableName::Record::NameID::Predefined::FontFamilyName, | 200 SkOTTableName::Record::NameID::Predefined::FontFamilyName, |
201 SkOTTableName::Record::NameID::Predefined::PreferredFamily, | 201 SkOTTableName::Record::NameID::Predefined::PreferredFamily, |
202 SkOTTableName::Record::NameID::Predefined::WWSFamilyName, | 202 SkOTTableName::Record::NameID::Predefined::WWSFamilyName, |
203 }; | 203 }; |
OLD | NEW |