| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 240 |
| 241 const char checksumTrailer[] = | 241 const char checksumTrailer[] = |
| 242 "};" "\n" | 242 "};" "\n" |
| 243 "" "\n" | 243 "" "\n" |
| 244 "static const int whitelistCount = (int) SK_ARRAY_COUNT(whitelist);" "\n"
; | 244 "static const int whitelistCount = (int) SK_ARRAY_COUNT(whitelist);" "\n"
; |
| 245 | 245 |
| 246 | 246 |
| 247 #include "SkOSFile.h" | 247 #include "SkOSFile.h" |
| 248 | 248 |
| 249 bool GenerateChecksums() { | 249 bool GenerateChecksums() { |
| 250 SkFILE* file = sk_fopen(checksumFileName, kWrite_SkFILE_Flag); | 250 FILE* file = sk_fopen(checksumFileName, kWrite_SkFILE_Flag); |
| 251 if (!file) { | 251 if (!file) { |
| 252 SkDebugf("Can't open %s for writing.\n", checksumFileName); | 252 SkDebugf("Can't open %s for writing.\n", checksumFileName); |
| 253 return false; | 253 return false; |
| 254 } | 254 } |
| 255 SkString line; | 255 SkString line; |
| 256 line.printf(checksumHeader, __FUNCTION__, __FILE__, checksumFileName); | 256 line.printf(checksumHeader, __FUNCTION__, __FILE__, checksumFileName); |
| 257 sk_fwrite(line.c_str(), line.size(), file); | 257 sk_fwrite(line.c_str(), line.size(), file); |
| 258 for (int i = 0; i < whitelistCount; ++i) { | 258 for (int i = 0; i < whitelistCount; ++i) { |
| 259 const char* fontName = whitelist[i].fFontName; | 259 const char* fontName = whitelist[i].fFontName; |
| 260 SkTypeface* tf = SkTypeface::CreateFromName(fontName, SkTypeface::kNorma
l); | 260 SkTypeface* tf = SkTypeface::CreateFromName(fontName, SkTypeface::kNorma
l); |
| 261 uint32_t checksum = compute_checksum(tf); | 261 uint32_t checksum = compute_checksum(tf); |
| 262 line.printf(checksumEntry, fontName, checksum); | 262 line.printf(checksumEntry, fontName, checksum); |
| 263 sk_fwrite(line.c_str(), line.size(), file); | 263 sk_fwrite(line.c_str(), line.size(), file); |
| 264 } | 264 } |
| 265 sk_fwrite(checksumTrailer, sizeof(checksumTrailer) - 1, file); | 265 sk_fwrite(checksumTrailer, sizeof(checksumTrailer) - 1, file); |
| 266 sk_fclose(file); | 266 sk_fclose(file); |
| 267 return true; | 267 return true; |
| 268 } | 268 } |
| OLD | NEW |