Chromium Code Reviews| Index: chrome/common/font_family_scripts_generator.cc |
| diff --git a/chrome/common/font_family_scripts_generator.cc b/chrome/common/font_family_scripts_generator.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5ffb95ed09e61ca6226cb49e2b8f1dccb568ed46 |
| --- /dev/null |
| +++ b/chrome/common/font_family_scripts_generator.cc |
| @@ -0,0 +1,42 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <stdio.h> |
| + |
| +#include <string> |
| + |
| +#include "chrome/common/pref_names.h" |
| + |
| +// A simple executable to auto-generate a header file used by |
| +// prefs_tab_helper.cc. This avoids the string-construction and heap allocation |
| +// 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
|
| +void UnrollMap(FILE* f, const char* map_name) { |
| + for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { |
| + const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; |
| + fprintf(f, "\"%s.%s\",\n", map_name, script); |
| + } |
| +} |
| + |
| +void GenerateMap(FILE* f) { |
| + static const char* const kMaps[] = { |
| + prefs::kWebKitStandardFontFamilyMap, |
| + prefs::kWebKitFixedFontFamilyMap, |
| + prefs::kWebKitSerifFontFamilyMap, |
| + prefs::kWebKitSansSerifFontFamilyMap, |
| + prefs::kWebKitCursiveFontFamilyMap, |
| + prefs::kWebKitFantasyFontFamilyMap, |
| + prefs::kWebKitPictographFontFamilyMap, |
| + }; |
| + |
| + fprintf(f, "static const char* const kFontFamilyScripts[] = {\n"); |
| + for (size_t i = 0; i < sizeof(kMaps) / sizeof(kMaps[0]); ++i) |
| + UnrollMap(f, kMaps[i]); |
| + fprintf(f, "};\n"); |
| +} |
| + |
| +int main(int argc, char** argv) { |
| + FILE* f = argc < 2 ? stdout : fopen(argv[1], "w"); |
| + GenerateMap(f); |
| + return 0; |
| +} |