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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_common.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« 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