| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webkit_test_platform_support.h" | 5 #include "content/shell/webkit_test_platform_support.h" |
| 6 | 6 |
| 7 #include <iostream> | 7 #include <iostream> |
| 8 | 8 |
| 9 #include <fontconfig/fontconfig.h> | 9 #include <fontconfig/fontconfig.h> |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // The DejaVuSans font is used by the css2.1 tests. | 71 // The DejaVuSans font is used by the css2.1 tests. |
| 72 "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf", | 72 "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf", |
| 73 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_hi.ttf", | 73 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_hi.ttf", |
| 74 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_ta.ttf", | 74 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_ta.ttf", |
| 75 "/usr/share/fonts/truetype/ttf-indic-fonts-core/MuktiNarrow.ttf", | 75 "/usr/share/fonts/truetype/ttf-indic-fonts-core/MuktiNarrow.ttf", |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 bool SetupFontConfig() { | 78 bool SetupFontConfig() { |
| 79 FcInit(); | 79 FcInit(); |
| 80 | 80 |
| 81 FilePath base_path; | 81 base::FilePath base_path; |
| 82 PathService::Get(base::DIR_MODULE, &base_path); | 82 PathService::Get(base::DIR_MODULE, &base_path); |
| 83 FilePath fonts_conf = base_path.Append(FILE_PATH_LITERAL("fonts.conf")); | 83 base::FilePath fonts_conf = base_path.Append(FILE_PATH_LITERAL("fonts.conf")); |
| 84 | 84 |
| 85 FcConfig* font_config = FcConfigCreate(); | 85 FcConfig* font_config = FcConfigCreate(); |
| 86 if (!FcConfigParseAndLoad( | 86 if (!FcConfigParseAndLoad( |
| 87 font_config, | 87 font_config, |
| 88 reinterpret_cast<const FcChar8*>(fonts_conf.value().c_str()), | 88 reinterpret_cast<const FcChar8*>(fonts_conf.value().c_str()), |
| 89 true)) { | 89 true)) { |
| 90 std::cerr << "Failed to parse fontconfig config file\n"; | 90 std::cerr << "Failed to parse fontconfig config file\n"; |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 | 93 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 112 return false; | 112 return false; |
| 113 } | 113 } |
| 114 | 114 |
| 115 // We special case these fonts because they're only needed in a few layout | 115 // We special case these fonts because they're only needed in a few layout |
| 116 // tests. | 116 // tests. |
| 117 CheckAndLoadFontFile( | 117 CheckAndLoadFontFile( |
| 118 font_config, | 118 font_config, |
| 119 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf", | 119 "/usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_pa.ttf", |
| 120 "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf"); | 120 "/usr/share/fonts/truetype/ttf-punjabi-fonts/lohit_pa.ttf"); |
| 121 | 121 |
| 122 FilePath ahem_font = base_path.Append("AHEM____.TTF"); | 122 base::FilePath ahem_font = base_path.Append("AHEM____.TTF"); |
| 123 if (!FcConfigAppFontAddFile( | 123 if (!FcConfigAppFontAddFile( |
| 124 font_config, | 124 font_config, |
| 125 reinterpret_cast<const FcChar8*>(ahem_font.value().c_str()))) { | 125 reinterpret_cast<const FcChar8*>(ahem_font.value().c_str()))) { |
| 126 std::cerr << "Failed to load font " << ahem_font.value() << "\n"; | 126 std::cerr << "Failed to load font " << ahem_font.value() << "\n"; |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 | 129 |
| 130 if (!FcConfigSetCurrent(font_config)) { | 130 if (!FcConfigSetCurrent(font_config)) { |
| 131 std::cerr << "Failed to set the default font configuration\n"; | 131 std::cerr << "Failed to set the default font configuration\n"; |
| 132 return false; | 132 return false; |
| 133 } | 133 } |
| 134 | 134 |
| 135 return true; | 135 return true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace | 138 } // namespace |
| 139 | 139 |
| 140 bool WebKitTestPlatformInitialize() { | 140 bool WebKitTestPlatformInitialize() { |
| 141 return SetupFontConfig(); | 141 return SetupFontConfig(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace content | 144 } // namespace content |
| OLD | NEW |