| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkChecksum.h" | 8 #include "SkChecksum.h" |
| 9 #include "SkFontDescriptor.h" | 9 #include "SkFontDescriptor.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 177 } |
| 178 SkDebugf("checksum updated\n"); | 178 SkDebugf("checksum updated\n"); |
| 179 SkDebugf(" { \"%s\", 0x%08x },\n", fontName, checksum); | 179 SkDebugf(" { \"%s\", 0x%08x },\n", fontName, checksum); |
| 180 #endif | 180 #endif |
| 181 whitelist[whitelistIndex].fChecksum = checksum; | 181 whitelist[whitelistIndex].fChecksum = checksum; |
| 182 } | 182 } |
| 183 serialize_sub(fontName, tf->style(), wstream); | 183 serialize_sub(fontName, tf->style(), wstream); |
| 184 } | 184 } |
| 185 | 185 |
| 186 SkTypeface* WhitelistDeserializeTypeface(SkStream* stream) { | 186 SkTypeface* WhitelistDeserializeTypeface(SkStream* stream) { |
| 187 SkFontDescriptor desc(stream); | 187 SkFontDescriptor desc; |
| 188 if (!SkFontDescriptor::Deserialize(stream, &desc)) { |
| 189 return nullptr; |
| 190 } |
| 191 |
| 188 SkFontData* data = desc.detachFontData(); | 192 SkFontData* data = desc.detachFontData(); |
| 189 if (data) { | 193 if (data) { |
| 190 SkTypeface* typeface = SkTypeface::CreateFromFontData(data); | 194 SkTypeface* typeface = SkTypeface::CreateFromFontData(data); |
| 191 if (typeface) { | 195 if (typeface) { |
| 192 return typeface; | 196 return typeface; |
| 193 } | 197 } |
| 194 } | 198 } |
| 195 const char* familyName = desc.getFamilyName(); | 199 const char* familyName = desc.getFamilyName(); |
| 196 if (!strncmp(SUBNAME_PREFIX, familyName, sizeof(SUBNAME_PREFIX) - 1)) { | 200 if (!strncmp(SUBNAME_PREFIX, familyName, sizeof(SUBNAME_PREFIX) - 1)) { |
| 197 familyName += sizeof(SUBNAME_PREFIX) - 1; | 201 familyName += sizeof(SUBNAME_PREFIX) - 1; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 const char* fontName = whitelist[i].fFontName; | 263 const char* fontName = whitelist[i].fFontName; |
| 260 SkTypeface* tf = SkTypeface::CreateFromName(fontName, SkTypeface::kNorma
l); | 264 SkTypeface* tf = SkTypeface::CreateFromName(fontName, SkTypeface::kNorma
l); |
| 261 uint32_t checksum = compute_checksum(tf); | 265 uint32_t checksum = compute_checksum(tf); |
| 262 line.printf(checksumEntry, fontName, checksum); | 266 line.printf(checksumEntry, fontName, checksum); |
| 263 sk_fwrite(line.c_str(), line.size(), file); | 267 sk_fwrite(line.c_str(), line.size(), file); |
| 264 } | 268 } |
| 265 sk_fwrite(checksumTrailer, sizeof(checksumTrailer) - 1, file); | 269 sk_fwrite(checksumTrailer, sizeof(checksumTrailer) - 1, file); |
| 266 sk_fclose(file); | 270 sk_fclose(file); |
| 267 return true; | 271 return true; |
| 268 } | 272 } |
| OLD | NEW |