Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <stdio.h> | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "chrome/common/pref_names.h" | |
| 10 | |
| 11 // A simple executable to auto-generate a header file used by | |
| 12 // prefs_tab_helper.cc. This avoids the string-construction and heap allocation | |
| 13 // at startup time by using RO data section. | |
|
Bernhard Bauer
2013/03/19 14:44:51
Is there any reason you're doing this in C++ inste
bulach
2013/03/19 15:35:16
yeah, I wished I could do a script.. :)
the reason
Bernhard Bauer
2013/03/19 16:06:38
Hm... how about the following:
#define DEFINE_FON
bulach
2013/03/19 16:18:17
the problem is that the "Afak", "Arab", ... "Xyzzy
| |
| 14 void UnrollMap(FILE* f, const char* map_name) { | |
| 15 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { | |
| 16 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; | |
| 17 fprintf(f, "\"%s.%s\",\n", map_name, script); | |
| 18 } | |
| 19 } | |
| 20 | |
| 21 void GenerateMap(FILE* f) { | |
| 22 static const char* const kMaps[] = { | |
| 23 prefs::kWebKitStandardFontFamilyMap, | |
| 24 prefs::kWebKitFixedFontFamilyMap, | |
| 25 prefs::kWebKitSerifFontFamilyMap, | |
| 26 prefs::kWebKitSansSerifFontFamilyMap, | |
| 27 prefs::kWebKitCursiveFontFamilyMap, | |
| 28 prefs::kWebKitFantasyFontFamilyMap, | |
| 29 prefs::kWebKitPictographFontFamilyMap, | |
| 30 }; | |
| 31 | |
| 32 fprintf(f, "static const char* const kFontFamilyScripts[] = {\n"); | |
| 33 for (size_t i = 0; i < sizeof(kMaps) / sizeof(kMaps[0]); ++i) | |
| 34 UnrollMap(f, kMaps[i]); | |
| 35 fprintf(f, "};\n"); | |
| 36 } | |
| 37 | |
| 38 int main(int argc, char** argv) { | |
| 39 FILE* f = argc < 2 ? stdout : fopen(argv[1], "w"); | |
| 40 GenerateMap(f); | |
| 41 return 0; | |
| 42 } | |
| OLD | NEW |