| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 // running create_test_font generates ./tools/test_font_data.cpp | 8 // running create_test_font generates ./tools/test_font_data.cpp |
| 9 // which is read by ./tools/sk_tool_utils_font.cpp | 9 // which is read by ./tools/sk_tool_utils_font.cpp |
| 10 | 10 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 for (int index = 0; index < gWritten.count(); ++index) { | 320 for (int index = 0; index < gWritten.count(); ++index) { |
| 321 const FontWritten& writ = gWritten[index]; | 321 const FontWritten& writ = gWritten[index]; |
| 322 if (!strcmp(fontDesc.fFont, writ.fName) && fontDesc.fStyle == writ.fStyl
e) { | 322 if (!strcmp(fontDesc.fFont, writ.fName) && fontDesc.fStyle == writ.fStyl
e) { |
| 323 return index; | 323 return index; |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 return -1; | 326 return -1; |
| 327 } | 327 } |
| 328 | 328 |
| 329 static void generate_fonts() { | 329 static void generate_fonts() { |
| 330 FILE* out = NULL; | 330 FILE* out = nullptr; |
| 331 for (int index = 0; index < gFontsCount; ++index) { | 331 for (int index = 0; index < gFontsCount; ++index) { |
| 332 FontDesc& fontDesc = gFonts[index]; | 332 FontDesc& fontDesc = gFonts[index]; |
| 333 if ((index & 3) == 0) { | 333 if ((index & 3) == 0) { |
| 334 out = font_header(fontDesc.fName); | 334 out = font_header(fontDesc.fName); |
| 335 } | 335 } |
| 336 int fontIndex = written_index(fontDesc); | 336 int fontIndex = written_index(fontDesc); |
| 337 if (fontIndex >= 0) { | 337 if (fontIndex >= 0) { |
| 338 fontDesc.fFontIndex = fontIndex; | 338 fontDesc.fFontIndex = fontIndex; |
| 339 continue; | 339 continue; |
| 340 } | 340 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 fprintf(out, "static SkTestFontData gTestFonts[] = {\n"); | 384 fprintf(out, "static SkTestFontData gTestFonts[] = {\n"); |
| 385 for (fontIndex = 0; fontIndex < fontCount; ++fontIndex) { | 385 for (fontIndex = 0; fontIndex < fontCount; ++fontIndex) { |
| 386 const FontWritten& writ = gWritten[fontIndex]; | 386 const FontWritten& writ = gWritten[fontIndex]; |
| 387 const char* name = writ.fName; | 387 const char* name = writ.fName; |
| 388 SkString strippedStr = strip_spaces(SkString(name)); | 388 SkString strippedStr = strip_spaces(SkString(name)); |
| 389 strippedStr.appendf("%s", gStyleName[writ.fStyle]); | 389 strippedStr.appendf("%s", gStyleName[writ.fStyle]); |
| 390 const char* strip = strippedStr.c_str(); | 390 const char* strip = strippedStr.c_str(); |
| 391 fprintf(out, | 391 fprintf(out, |
| 392 " { %sPoints, %sVerbs, %sCharCodes,\n" | 392 " { %sPoints, %sVerbs, %sCharCodes,\n" |
| 393 " %sCharCodesCount, %sWidths,\n" | 393 " %sCharCodesCount, %sWidths,\n" |
| 394 " %sMetrics, \"Toy %s\", SkTypeface::k%s, NULL\n" | 394 " %sMetrics, \"Toy %s\", SkTypeface::k%s, nullptr\n" |
| 395 " },\n", | 395 " },\n", |
| 396 strip, strip, strip, strip, strip, strip, name, gStyleName[writ.
fStyle]); | 396 strip, strip, strip, strip, strip, strip, name, gStyleName[writ.
fStyle]); |
| 397 } | 397 } |
| 398 fprintf(out, "};\n\n"); | 398 fprintf(out, "};\n\n"); |
| 399 fprintf(out, "const int gTestFontsCount = (int) SK_ARRAY_COUNT(gTestFonts);\
n\n"); | 399 fprintf(out, "const int gTestFontsCount = (int) SK_ARRAY_COUNT(gTestFonts);\
n\n"); |
| 400 fprintf(out, | 400 fprintf(out, |
| 401 "struct SubFont {\n" | 401 "struct SubFont {\n" |
| 402 " const char* fName;\n" | 402 " const char* fName;\n" |
| 403 " SkTypeface::Style fStyle;\n" | 403 " SkTypeface::Style fStyle;\n" |
| 404 " SkTestFontData& fFont;\n" | 404 " SkTestFontData& fFont;\n" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 429 } | 429 } |
| 430 | 430 |
| 431 int main(int , char * const []) { | 431 int main(int , char * const []) { |
| 432 #ifndef SK_BUILD_FOR_MAC | 432 #ifndef SK_BUILD_FOR_MAC |
| 433 #error "use fonts installed on Mac" | 433 #error "use fonts installed on Mac" |
| 434 #endif | 434 #endif |
| 435 generate_fonts(); | 435 generate_fonts(); |
| 436 generate_index(DEFAULT_FONT_NAME); | 436 generate_index(DEFAULT_FONT_NAME); |
| 437 return 0; | 437 return 0; |
| 438 } | 438 } |
| OLD | NEW |