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

Side by Side Diff: ui/gfx/test/fontconfig_util_linux.cc

Issue 2104653002: Fix content shell layout test failure related to Fontconfig (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
msw 2016/06/27 22:14:45 nit: keep this blank line between include types?
9 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
10 #include "base/logging.h" 9 #include "base/logging.h"
11 #include "base/macros.h" 10 #include "base/macros.h"
12 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
14 13
15 namespace gfx { 14 namespace gfx {
16 15
17 const char* const kSystemFontsForFontconfig[] = { 16 const char* const kSystemFontsForFontconfig[] = {
18 "/usr/share/fonts/truetype/kochi/kochi-gothic.ttf", 17 "/usr/share/fonts/truetype/kochi/kochi-gothic.ttf",
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const char kFontconfigFileHeader[] = 56 const char kFontconfigFileHeader[] =
58 "<?xml version=\"1.0\"?>\n" 57 "<?xml version=\"1.0\"?>\n"
59 "<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">\n" 58 "<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">\n"
60 "<fontconfig>\n"; 59 "<fontconfig>\n";
61 const char kFontconfigFileFooter[] = "</fontconfig>"; 60 const char kFontconfigFileFooter[] = "</fontconfig>";
62 const char kFontconfigMatchFontHeader[] = " <match target=\"font\">\n"; 61 const char kFontconfigMatchFontHeader[] = " <match target=\"font\">\n";
63 const char kFontconfigMatchPatternHeader[] = " <match target=\"pattern\">\n"; 62 const char kFontconfigMatchPatternHeader[] = " <match target=\"pattern\">\n";
64 const char kFontconfigMatchFooter[] = " </match>\n"; 63 const char kFontconfigMatchFooter[] = " </match>\n";
65 64
66 void SetUpFontconfig() { 65 void SetUpFontconfig() {
67 FcInit(); 66 CHECK(FcInit());
68 67 CHECK(FcConfigGetCurrent());
69 // A primer on undocumented FcConfig reference-counting:
70 //
71 // - FcConfigCreate() creates a config with a refcount of 1.
72 // - FcConfigReference() increments a config's refcount.
73 // - FcConfigDestroy() decrements a config's refcount, deallocating the
74 // config when the count reaches 0.
75 // - FcConfigSetCurrent() calls FcConfigDestroy() on the old config, but
76 // interestingly does not call FcConfigReference() on the new config.
77 CHECK(FcConfigSetCurrent(FcConfigCreate()));
78 } 68 }
79 69
80 void TearDownFontconfig() { 70 void TearDownFontconfig() {
81 FcFini(); 71 FcFini();
82 } 72 }
83 73
84 bool LoadFontIntoFontconfig(const base::FilePath& path) { 74 bool LoadFontIntoFontconfig(const base::FilePath& path) {
85 if (!base::PathExists(path)) { 75 if (!base::PathExists(path)) {
86 LOG(ERROR) << "You are missing " << path.value() << ". Try re-running " 76 LOG(ERROR) << "You are missing " << path.value() << ". Try re-running "
87 << "build/install-build-deps.sh. Also see " 77 << "build/install-build-deps.sh. Also see "
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 const std::string& preferred_family) { 149 const std::string& preferred_family) {
160 return base::StringPrintf( 150 return base::StringPrintf(
161 " <alias>\n" 151 " <alias>\n"
162 " <family>%s</family>\n" 152 " <family>%s</family>\n"
163 " <prefer><family>%s</family></prefer>\n" 153 " <prefer><family>%s</family></prefer>\n"
164 " </alias>\n", 154 " </alias>\n",
165 original_family.c_str(), preferred_family.c_str()); 155 original_family.c_str(), preferred_family.c_str());
166 } 156 }
167 157
168 } // namespace gfx 158 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698