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

Side by Side Diff: content/shell/app/webkit_test_platform_support_linux.cc

Issue 356733003: Enable layout testing support for font fallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Variable name case fix. Created 6 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/app/webkit_test_platform_support.h" 5 #include "content/shell/app/webkit_test_platform_support.h"
6 6
7 #include <fontconfig/fontconfig.h> 7 #include <fontconfig/fontconfig.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include <iostream> 10 #include <iostream>
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 } 32 }
33 if (!FcConfigAppFontAddFile( 33 if (!FcConfigAppFontAddFile(
34 fontcfg, reinterpret_cast<const FcChar8*>(font))) { 34 fontcfg, reinterpret_cast<const FcChar8*>(font))) {
35 std::cerr << "Failed to load font " << font << "\n"; 35 std::cerr << "Failed to load font " << font << "\n";
36 return false; 36 return false;
37 } 37 }
38 return true; 38 return true;
39 } 39 }
40 40
41 static bool LoadFontResources(
42 const base::FilePath& base_path, FcConfig* font_config) {
piman 2014/06/25 18:43:31 indent looks wrong. Run "git cl format" ?
Dominik Röttsches 2014/06/26 11:21:55 Yep, sorry about that. Tried with git cl format no
43 const char* const own_fonts[] = {
44 "AHEM____.TTF",
45 "GardinerModBug.ttf",
46 "GardinerModCat.ttf"
47 };
48
49 for (size_t i = 0; i < arraysize(own_fonts); ++i) {
50 base::FilePath font_path = base_path.Append(own_fonts[i]);
51 if (access(font_path.value().c_str(), R_OK) < 0
52 || !FcConfigAppFontAddFile(font_config,
53 reinterpret_cast<const FcChar8*>(font_path.value().c_str()))) {
54 std::cerr << "Failed to load test font resource "
55 << font_path.value().c_str() << ".\n";
56 return false;
57 }
58 }
59 return true;
60 }
61
41 const char* const kFonts[] = { 62 const char* const kFonts[] = {
42 "/usr/share/fonts/truetype/kochi/kochi-gothic.ttf", 63 "/usr/share/fonts/truetype/kochi/kochi-gothic.ttf",
43 "/usr/share/fonts/truetype/kochi/kochi-mincho.ttf", 64 "/usr/share/fonts/truetype/kochi/kochi-mincho.ttf",
44 "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", 65 "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf",
45 "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf", 66 "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf",
46 "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf", 67 "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf",
47 "/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf", 68 "/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf",
48 "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf", 69 "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf",
49 "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf", 70 "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf",
50 "/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf", 71 "/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf",
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return false; 133 return false;
113 } 134 }
114 135
115 // We special case these fonts because they're only needed in a few layout 136 // We special case these fonts because they're only needed in a few layout
116 // tests. 137 // tests.
117 CheckAndLoadFontFile( 138 CheckAndLoadFontFile(
118 font_config, 139 font_config,
119 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf", 140 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf",
120 "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf"); 141 "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf");
121 142
122 base::FilePath ahem_font = base_path.Append("AHEM____.TTF"); 143 if (!LoadFontResources(base_path, font_config))
123 if (!FcConfigAppFontAddFile( 144 return false;
124 font_config,
125 reinterpret_cast<const FcChar8*>(ahem_font.value().c_str()))) {
126 std::cerr << "Failed to load font " << ahem_font.value() << "\n";
127 return false;
128 }
129 145
130 if (!FcConfigSetCurrent(font_config)) { 146 if (!FcConfigSetCurrent(font_config)) {
131 std::cerr << "Failed to set the default font configuration\n"; 147 std::cerr << "Failed to set the default font configuration\n";
132 return false; 148 return false;
133 } 149 }
134 150
135 return true; 151 return true;
136 } 152 }
137 153
138 } // namespace 154 } // namespace
139 155
140 bool CheckLayoutSystemDeps() { 156 bool CheckLayoutSystemDeps() {
141 return true; 157 return true;
142 } 158 }
143 159
144 bool WebKitTestPlatformInitialize() { 160 bool WebKitTestPlatformInitialize() {
145 return SetupFontConfig(); 161 return SetupFontConfig();
146 } 162 }
147 163
148 } // namespace content 164 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698