Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4741)

Unified Diff: chrome/common/font_family_scripts_generator.cc

Issue 12902021: Auto-generates the font family scripts at build time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/chrome_common.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « chrome/chrome_common.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698