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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 size_t nameTableLogicalSize = sizeof(SkOTTableName) + (namesCount * sizeof(S
kOTTableName::Record)) + (fontNameLen * sizeof(wchar_t)); | 76 size_t nameTableLogicalSize = sizeof(SkOTTableName) + (namesCount * sizeof(S
kOTTableName::Record)) + (fontNameLen * sizeof(wchar_t)); |
77 size_t nameTablePhysicalSize = (nameTableLogicalSize + 3) & ~3; // Rounded u
p to a multiple of 4. | 77 size_t nameTablePhysicalSize = (nameTableLogicalSize + 3) & ~3; // Rounded u
p to a multiple of 4. |
78 | 78 |
79 size_t oldNameTablePhysicalSize = (SkEndian_SwapBE32(tableEntry.logicalLengt
h) + 3) & ~3; // Rounded up to a multiple of 4. | 79 size_t oldNameTablePhysicalSize = (SkEndian_SwapBE32(tableEntry.logicalLengt
h) + 3) & ~3; // Rounded up to a multiple of 4. |
80 size_t oldNameTableOffset = SkEndian_SwapBE32(tableEntry.offset); | 80 size_t oldNameTableOffset = SkEndian_SwapBE32(tableEntry.offset); |
81 | 81 |
82 //originalDataSize is the size of the original data without the name table. | 82 //originalDataSize is the size of the original data without the name table. |
83 size_t originalDataSize = fontData->getLength() - oldNameTablePhysicalSize; | 83 size_t originalDataSize = fontData->getLength() - oldNameTablePhysicalSize; |
84 size_t newDataSize = originalDataSize + nameTablePhysicalSize; | 84 size_t newDataSize = originalDataSize + nameTablePhysicalSize; |
85 | 85 |
86 SK_OT_BYTE* data = static_cast<SK_OT_BYTE*>(sk_malloc_throw(newDataSize)); | 86 SkAutoTUnref<SkData> rewrittenFontData(SkData::NewUninitialized(newDataSize)
); |
87 SkAutoTUnref<SkData> rewrittenFontData(SkData::NewFromMalloc(data, newDataSi
ze)); | 87 SK_OT_BYTE* data = static_cast<SK_OT_BYTE*>(rewrittenFontData->writable_data
()); |
88 | 88 |
89 if (fontData->read(data, oldNameTableOffset) < oldNameTableOffset) { | 89 if (fontData->read(data, oldNameTableOffset) < oldNameTableOffset) { |
90 return NULL; | 90 return NULL; |
91 } | 91 } |
92 if (fontData->skip(oldNameTablePhysicalSize) < oldNameTablePhysicalSize) { | 92 if (fontData->skip(oldNameTablePhysicalSize) < oldNameTablePhysicalSize) { |
93 return NULL; | 93 return NULL; |
94 } | 94 } |
95 if (fontData->read(data + oldNameTableOffset, originalDataSize - oldNameTabl
eOffset) < originalDataSize - oldNameTableOffset) { | 95 if (fontData->read(data + oldNameTableOffset, originalDataSize - oldNameTabl
eOffset) < originalDataSize - oldNameTableOffset) { |
96 return NULL; | 96 return NULL; |
97 } | 97 } |
(...skipping 96 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 |