| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/gfx/test/fontconfig_util_linux.h" | 5 #include "ui/gfx/test/fontconfig_util_linux.h" |
| 6 | 6 |
| 7 #include <fontconfig/fontconfig.h> | 7 #include <fontconfig/fontconfig.h> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 LOG(ERROR) << "Failed to load font " << path.value(); | 93 LOG(ERROR) << "Failed to load font " << path.value(); |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 | 96 |
| 97 return true; | 97 return true; |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool LoadSystemFontIntoFontconfig(const std::string& basename) { | 100 bool LoadSystemFontIntoFontconfig(const std::string& basename) { |
| 101 for (size_t i = 0; i < kNumSystemFontsForFontconfig; ++i) { | 101 for (size_t i = 0; i < kNumSystemFontsForFontconfig; ++i) { |
| 102 base::FilePath path(kSystemFontsForFontconfig[i]); | 102 base::FilePath path(kSystemFontsForFontconfig[i]); |
| 103 if (base::strcasecmp(path.BaseName().value().c_str(), basename.c_str()) == | 103 if (base::EqualsCaseInsensitiveASCII(path.BaseName().value(), basename)) |
| 104 0) | |
| 105 return LoadFontIntoFontconfig(path); | 104 return LoadFontIntoFontconfig(path); |
| 106 } | 105 } |
| 107 LOG(ERROR) << "Unable to find system font named " << basename; | 106 LOG(ERROR) << "Unable to find system font named " << basename; |
| 108 return false; | 107 return false; |
| 109 } | 108 } |
| 110 | 109 |
| 111 bool LoadConfigFileIntoFontconfig(const base::FilePath& path) { | 110 bool LoadConfigFileIntoFontconfig(const base::FilePath& path) { |
| 112 // Unlike other FcConfig functions, FcConfigParseAndLoad() doesn't default to | 111 // Unlike other FcConfig functions, FcConfigParseAndLoad() doesn't default to |
| 113 // the current config when passed NULL. So that's cool. | 112 // the current config when passed NULL. So that's cool. |
| 114 if (!FcConfigParseAndLoad(FcConfigGetCurrent(), | 113 if (!FcConfigParseAndLoad(FcConfigGetCurrent(), |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 const std::string& preferred_family) { | 158 const std::string& preferred_family) { |
| 160 return base::StringPrintf( | 159 return base::StringPrintf( |
| 161 " <alias>\n" | 160 " <alias>\n" |
| 162 " <family>%s</family>\n" | 161 " <family>%s</family>\n" |
| 163 " <prefer><family>%s</family></prefer>\n" | 162 " <prefer><family>%s</family></prefer>\n" |
| 164 " </alias>\n", | 163 " </alias>\n", |
| 165 original_family.c_str(), preferred_family.c_str()); | 164 original_family.c_str(), preferred_family.c_str()); |
| 166 } | 165 } |
| 167 | 166 |
| 168 } // namespace gfx | 167 } // namespace gfx |
| OLD | NEW |