OLD | NEW |
---|---|
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 Loading... | |
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(const base::FilePath& base_path, | |
42 FcConfig* font_config) { | |
43 const char* const own_fonts[] = {"AHEM____.TTF", "GardinerModBug.ttf", | |
44 "GardinerModCat.ttf"}; | |
45 | |
46 for (size_t i = 0; i < arraysize(own_fonts); ++i) { | |
47 base::FilePath font_path = base_path.Append(own_fonts[i]); | |
48 if (access(font_path.value().c_str(), R_OK) < 0 || | |
49 !FcConfigAppFontAddFile( | |
50 font_config, | |
51 reinterpret_cast<const FcChar8*>(font_path.value().c_str()))) { | |
52 std::cerr << "Failed to load test font resource " | |
jamesr
2014/06/26 20:32:29
why doesn't this use base's loggig facilities? i s
| |
53 << font_path.value().c_str() << ".\n"; | |
54 return false; | |
55 } | |
56 } | |
57 return true; | |
58 } | |
59 | |
41 const char* const kFonts[] = { | 60 const char* const kFonts[] = { |
42 "/usr/share/fonts/truetype/kochi/kochi-gothic.ttf", | 61 "/usr/share/fonts/truetype/kochi/kochi-gothic.ttf", |
43 "/usr/share/fonts/truetype/kochi/kochi-mincho.ttf", | 62 "/usr/share/fonts/truetype/kochi/kochi-mincho.ttf", |
44 "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", | 63 "/usr/share/fonts/truetype/msttcorefonts/Arial.ttf", |
45 "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf", | 64 "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf", |
46 "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf", | 65 "/usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf", |
47 "/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf", | 66 "/usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf", |
48 "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf", | 67 "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf", |
49 "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf", | 68 "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf", |
50 "/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf", | 69 "/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf", |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 return false; | 131 return false; |
113 } | 132 } |
114 | 133 |
115 // We special case these fonts because they're only needed in a few layout | 134 // We special case these fonts because they're only needed in a few layout |
116 // tests. | 135 // tests. |
117 CheckAndLoadFontFile( | 136 CheckAndLoadFontFile( |
118 font_config, | 137 font_config, |
119 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf", | 138 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf", |
120 "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf"); | 139 "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf"); |
121 | 140 |
122 base::FilePath ahem_font = base_path.Append("AHEM____.TTF"); | 141 if (!LoadFontResources(base_path, font_config)) |
123 if (!FcConfigAppFontAddFile( | |
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; | 142 return false; |
128 } | |
129 | 143 |
130 if (!FcConfigSetCurrent(font_config)) { | 144 if (!FcConfigSetCurrent(font_config)) { |
131 std::cerr << "Failed to set the default font configuration\n"; | 145 std::cerr << "Failed to set the default font configuration\n"; |
132 return false; | 146 return false; |
133 } | 147 } |
134 | 148 |
135 return true; | 149 return true; |
136 } | 150 } |
137 | 151 |
138 } // namespace | 152 } // namespace |
139 | 153 |
140 bool CheckLayoutSystemDeps() { | 154 bool CheckLayoutSystemDeps() { |
141 return true; | 155 return true; |
142 } | 156 } |
143 | 157 |
144 bool WebKitTestPlatformInitialize() { | 158 bool WebKitTestPlatformInitialize() { |
145 return SetupFontConfig(); | 159 return SetupFontConfig(); |
146 } | 160 } |
147 | 161 |
148 } // namespace content | 162 } // namespace content |
OLD | NEW |