Chromium Code Reviews| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 | 65 |
| 66 void SetUpFontconfig() { | 66 void SetUpFontconfig() { |
| 67 FcInit(); | 67 FcInit(); |
| 68 | 68 |
| 69 // A primer on undocumented FcConfig reference-counting: | 69 // A primer on undocumented FcConfig reference-counting: |
| 70 // | 70 // |
| 71 // - FcConfigCreate() creates a config with a refcount of 1. | 71 // - FcConfigCreate() creates a config with a refcount of 1. |
| 72 // - FcConfigReference() increments a config's refcount. | 72 // - FcConfigReference() increments a config's refcount. |
| 73 // - FcConfigDestroy() decrements a config's refcount, deallocating the | 73 // - FcConfigDestroy() decrements a config's refcount, deallocating the |
| 74 // config when the count reaches 0. | 74 // config when the count reaches 0. |
| 75 // - FcConfigSetCurrent() calls FcConfigDestroy() on the old config, but | 75 // - FcConfigSetCurrent() calls FcConfigDestroy() on the old config, and |
| 76 // interestingly does not call FcConfigReference() on the new config. | 76 // calls FcConfigReference() on the new config. |
| 77 CHECK(FcConfigSetCurrent(FcConfigCreate())); | 77 FcConfig* config = FcConfigCreate(); |
| 78 FcConfigBuildFonts(config); | |
| 79 CHECK(FcConfigSetCurrent(config)); | |
|
Daniel Erat
2016/06/27 23:40:43
interesting. https://www.freedesktop.org/software/
| |
| 78 } | 80 } |
| 79 | 81 |
| 80 void TearDownFontconfig() { | 82 void TearDownFontconfig() { |
| 81 FcFini(); | 83 FcFini(); |
| 82 } | 84 } |
| 83 | 85 |
| 84 bool LoadFontIntoFontconfig(const base::FilePath& path) { | 86 bool LoadFontIntoFontconfig(const base::FilePath& path) { |
| 85 if (!base::PathExists(path)) { | 87 if (!base::PathExists(path)) { |
| 86 LOG(ERROR) << "You are missing " << path.value() << ". Try re-running " | 88 LOG(ERROR) << "You are missing " << path.value() << ". Try re-running " |
| 87 << "build/install-build-deps.sh. Also see " | 89 << "build/install-build-deps.sh. Also see " |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 const std::string& preferred_family) { | 161 const std::string& preferred_family) { |
| 160 return base::StringPrintf( | 162 return base::StringPrintf( |
| 161 " <alias>\n" | 163 " <alias>\n" |
| 162 " <family>%s</family>\n" | 164 " <family>%s</family>\n" |
| 163 " <prefer><family>%s</family></prefer>\n" | 165 " <prefer><family>%s</family></prefer>\n" |
| 164 " </alias>\n", | 166 " </alias>\n", |
| 165 original_family.c_str(), preferred_family.c_str()); | 167 original_family.c_str(), preferred_family.c_str()); |
| 166 } | 168 } |
| 167 | 169 |
| 168 } // namespace gfx | 170 } // namespace gfx |
| OLD | NEW |