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/font_render_params.h" | 5 #include "ui/gfx/font_render_params.h" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 base::ScopedTempDir temp_dir_; | 65 base::ScopedTempDir temp_dir_; |
66 const LinuxFontDelegate* original_font_delegate_; | 66 const LinuxFontDelegate* original_font_delegate_; |
67 TestFontDelegate test_font_delegate_; | 67 TestFontDelegate test_font_delegate_; |
68 | 68 |
69 private: | 69 private: |
70 DISALLOW_COPY_AND_ASSIGN(FontRenderParamsTest); | 70 DISALLOW_COPY_AND_ASSIGN(FontRenderParamsTest); |
71 }; | 71 }; |
72 | 72 |
73 TEST_F(FontRenderParamsTest, Default) { | 73 TEST_F(FontRenderParamsTest, Default) { |
74 ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); | 74 ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); |
75 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 75 ASSERT_TRUE(LoadConfigDataIntoFontconfig( |
| 76 temp_dir_.GetPath(), |
76 std::string(kFontconfigFileHeader) + | 77 std::string(kFontconfigFileHeader) + |
77 // Specify the desired defaults via a font match rather than a pattern | 78 // Specify the desired defaults via a font match rather than a pattern |
78 // match (since this is the style generally used in /etc/fonts/conf.d). | 79 // match (since this is the style generally used in |
79 kFontconfigMatchFontHeader + | 80 // /etc/fonts/conf.d). |
80 CreateFontconfigEditStanza("antialias", "bool", "true") + | 81 kFontconfigMatchFontHeader + |
81 CreateFontconfigEditStanza("autohint", "bool", "true") + | 82 CreateFontconfigEditStanza("antialias", "bool", "true") + |
82 CreateFontconfigEditStanza("hinting", "bool", "true") + | 83 CreateFontconfigEditStanza("autohint", "bool", "true") + |
83 CreateFontconfigEditStanza("hintstyle", "const", "hintslight") + | 84 CreateFontconfigEditStanza("hinting", "bool", "true") + |
84 CreateFontconfigEditStanza("rgba", "const", "rgb") + | 85 CreateFontconfigEditStanza("hintstyle", "const", "hintslight") + |
85 kFontconfigMatchFooter + | 86 CreateFontconfigEditStanza("rgba", "const", "rgb") + |
86 // Add a font match for Arial. Since it specifies a family, it shouldn't | 87 kFontconfigMatchFooter + |
87 // take effect when querying default settings. | 88 // Add a font match for Arial. Since it specifies a family, it |
88 kFontconfigMatchFontHeader + | 89 // shouldn't |
89 CreateFontconfigTestStanza("family", "eq", "string", "Arial") + | 90 // take effect when querying default settings. |
90 CreateFontconfigEditStanza("antialias", "bool", "true") + | 91 kFontconfigMatchFontHeader + |
91 CreateFontconfigEditStanza("autohint", "bool", "false") + | 92 CreateFontconfigTestStanza("family", "eq", "string", "Arial") + |
92 CreateFontconfigEditStanza("hinting", "bool", "true") + | 93 CreateFontconfigEditStanza("antialias", "bool", "true") + |
93 CreateFontconfigEditStanza("hintstyle", "const", "hintfull") + | 94 CreateFontconfigEditStanza("autohint", "bool", "false") + |
94 CreateFontconfigEditStanza("rgba", "const", "none") + | 95 CreateFontconfigEditStanza("hinting", "bool", "true") + |
95 kFontconfigMatchFooter + | 96 CreateFontconfigEditStanza("hintstyle", "const", "hintfull") + |
96 // Add font matches for fonts between 10 and 20 points or pixels. Since | 97 CreateFontconfigEditStanza("rgba", "const", "none") + |
97 // they specify sizes, they also should not affect the defaults. | 98 kFontconfigMatchFooter + |
98 kFontconfigMatchFontHeader + | 99 // Add font matches for fonts between 10 and 20 points or pixels. |
99 CreateFontconfigTestStanza("size", "more_eq", "double", "10.0") + | 100 // Since |
100 CreateFontconfigTestStanza("size", "less_eq", "double", "20.0") + | 101 // they specify sizes, they also should not affect the defaults. |
101 CreateFontconfigEditStanza("antialias", "bool", "false") + | 102 kFontconfigMatchFontHeader + |
102 kFontconfigMatchFooter + | 103 CreateFontconfigTestStanza("size", "more_eq", "double", "10.0") + |
103 kFontconfigMatchFontHeader + | 104 CreateFontconfigTestStanza("size", "less_eq", "double", "20.0") + |
104 CreateFontconfigTestStanza("pixel_size", "more_eq", "double", "10.0") + | 105 CreateFontconfigEditStanza("antialias", "bool", "false") + |
105 CreateFontconfigTestStanza("pixel_size", "less_eq", "double", "20.0") + | 106 kFontconfigMatchFooter + kFontconfigMatchFontHeader + |
106 CreateFontconfigEditStanza("antialias", "bool", "false") + | 107 CreateFontconfigTestStanza("pixel_size", "more_eq", "double", |
107 kFontconfigMatchFooter + | 108 "10.0") + |
108 kFontconfigFileFooter)); | 109 CreateFontconfigTestStanza("pixel_size", "less_eq", "double", |
| 110 "20.0") + |
| 111 CreateFontconfigEditStanza("antialias", "bool", "false") + |
| 112 kFontconfigMatchFooter + kFontconfigFileFooter)); |
109 | 113 |
110 FontRenderParams params = GetFontRenderParams( | 114 FontRenderParams params = GetFontRenderParams( |
111 FontRenderParamsQuery(), NULL); | 115 FontRenderParamsQuery(), NULL); |
112 EXPECT_TRUE(params.antialiasing); | 116 EXPECT_TRUE(params.antialiasing); |
113 EXPECT_TRUE(params.autohinter); | 117 EXPECT_TRUE(params.autohinter); |
114 EXPECT_TRUE(params.use_bitmaps); | 118 EXPECT_TRUE(params.use_bitmaps); |
115 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); | 119 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); |
116 EXPECT_FALSE(params.subpixel_positioning); | 120 EXPECT_FALSE(params.subpixel_positioning); |
117 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB, | 121 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB, |
118 params.subpixel_rendering); | 122 params.subpixel_rendering); |
119 } | 123 } |
120 | 124 |
121 TEST_F(FontRenderParamsTest, Size) { | 125 TEST_F(FontRenderParamsTest, Size) { |
122 ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); | 126 ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); |
123 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 127 ASSERT_TRUE(LoadConfigDataIntoFontconfig( |
124 std::string(kFontconfigFileHeader) + | 128 temp_dir_.GetPath(), |
125 kFontconfigMatchPatternHeader + | 129 std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader + |
126 CreateFontconfigEditStanza("antialias", "bool", "true") + | 130 CreateFontconfigEditStanza("antialias", "bool", "true") + |
127 CreateFontconfigEditStanza("hinting", "bool", "true") + | 131 CreateFontconfigEditStanza("hinting", "bool", "true") + |
128 CreateFontconfigEditStanza("hintstyle", "const", "hintfull") + | 132 CreateFontconfigEditStanza("hintstyle", "const", "hintfull") + |
129 CreateFontconfigEditStanza("rgba", "const", "none") + | 133 CreateFontconfigEditStanza("rgba", "const", "none") + |
130 kFontconfigMatchFooter + | 134 kFontconfigMatchFooter + kFontconfigMatchPatternHeader + |
131 kFontconfigMatchPatternHeader + | 135 CreateFontconfigTestStanza("pixelsize", "less_eq", "double", "10") + |
132 CreateFontconfigTestStanza("pixelsize", "less_eq", "double", "10") + | 136 CreateFontconfigEditStanza("antialias", "bool", "false") + |
133 CreateFontconfigEditStanza("antialias", "bool", "false") + | 137 kFontconfigMatchFooter + kFontconfigMatchPatternHeader + |
134 kFontconfigMatchFooter + | 138 CreateFontconfigTestStanza("size", "more_eq", "double", "20") + |
135 kFontconfigMatchPatternHeader + | 139 CreateFontconfigEditStanza("hintstyle", "const", "hintslight") + |
136 CreateFontconfigTestStanza("size", "more_eq", "double", "20") + | 140 CreateFontconfigEditStanza("rgba", "const", "rgb") + |
137 CreateFontconfigEditStanza("hintstyle", "const", "hintslight") + | 141 kFontconfigMatchFooter + kFontconfigFileFooter)); |
138 CreateFontconfigEditStanza("rgba", "const", "rgb") + | |
139 kFontconfigMatchFooter + | |
140 kFontconfigFileFooter)); | |
141 | 142 |
142 // The defaults should be used when the supplied size isn't matched by the | 143 // The defaults should be used when the supplied size isn't matched by the |
143 // second or third blocks. | 144 // second or third blocks. |
144 FontRenderParamsQuery query; | 145 FontRenderParamsQuery query; |
145 query.pixel_size = 12; | 146 query.pixel_size = 12; |
146 FontRenderParams params = GetFontRenderParams(query, NULL); | 147 FontRenderParams params = GetFontRenderParams(query, NULL); |
147 EXPECT_TRUE(params.antialiasing); | 148 EXPECT_TRUE(params.antialiasing); |
148 EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting); | 149 EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting); |
149 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE, | 150 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE, |
150 params.subpixel_rendering); | 151 params.subpixel_rendering); |
(...skipping 11 matching lines...) Expand all Loading... |
162 EXPECT_TRUE(params.antialiasing); | 163 EXPECT_TRUE(params.antialiasing); |
163 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); | 164 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); |
164 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB, | 165 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB, |
165 params.subpixel_rendering); | 166 params.subpixel_rendering); |
166 } | 167 } |
167 | 168 |
168 TEST_F(FontRenderParamsTest, Style) { | 169 TEST_F(FontRenderParamsTest, Style) { |
169 ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); | 170 ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); |
170 // Load a config that disables subpixel rendering for bold text and disables | 171 // Load a config that disables subpixel rendering for bold text and disables |
171 // hinting for italic text. | 172 // hinting for italic text. |
172 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 173 ASSERT_TRUE(LoadConfigDataIntoFontconfig( |
173 std::string(kFontconfigFileHeader) + | 174 temp_dir_.GetPath(), |
174 kFontconfigMatchPatternHeader + | 175 std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader + |
175 CreateFontconfigEditStanza("antialias", "bool", "true") + | 176 CreateFontconfigEditStanza("antialias", "bool", "true") + |
176 CreateFontconfigEditStanza("hinting", "bool", "true") + | 177 CreateFontconfigEditStanza("hinting", "bool", "true") + |
177 CreateFontconfigEditStanza("hintstyle", "const", "hintslight") + | 178 CreateFontconfigEditStanza("hintstyle", "const", "hintslight") + |
178 CreateFontconfigEditStanza("rgba", "const", "rgb") + | 179 CreateFontconfigEditStanza("rgba", "const", "rgb") + |
179 kFontconfigMatchFooter + | 180 kFontconfigMatchFooter + kFontconfigMatchPatternHeader + |
180 kFontconfigMatchPatternHeader + | 181 CreateFontconfigTestStanza("weight", "eq", "const", "bold") + |
181 CreateFontconfigTestStanza("weight", "eq", "const", "bold") + | 182 CreateFontconfigEditStanza("rgba", "const", "none") + |
182 CreateFontconfigEditStanza("rgba", "const", "none") + | 183 kFontconfigMatchFooter + kFontconfigMatchPatternHeader + |
183 kFontconfigMatchFooter + | 184 CreateFontconfigTestStanza("slant", "eq", "const", "italic") + |
184 kFontconfigMatchPatternHeader + | 185 CreateFontconfigEditStanza("hinting", "bool", "false") + |
185 CreateFontconfigTestStanza("slant", "eq", "const", "italic") + | 186 kFontconfigMatchFooter + kFontconfigFileFooter)); |
186 CreateFontconfigEditStanza("hinting", "bool", "false") + | |
187 kFontconfigMatchFooter + | |
188 kFontconfigFileFooter)); | |
189 | 187 |
190 FontRenderParamsQuery query; | 188 FontRenderParamsQuery query; |
191 query.style = Font::NORMAL; | 189 query.style = Font::NORMAL; |
192 FontRenderParams params = GetFontRenderParams(query, NULL); | 190 FontRenderParams params = GetFontRenderParams(query, NULL); |
193 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); | 191 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); |
194 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB, | 192 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB, |
195 params.subpixel_rendering); | 193 params.subpixel_rendering); |
196 | 194 |
197 query.weight = Font::Weight::BOLD; | 195 query.weight = Font::Weight::BOLD; |
198 params = GetFontRenderParams(query, NULL); | 196 params = GetFontRenderParams(query, NULL); |
(...skipping 11 matching lines...) Expand all Loading... |
210 query.weight = Font::Weight::BOLD; | 208 query.weight = Font::Weight::BOLD; |
211 query.style = Font::ITALIC; | 209 query.style = Font::ITALIC; |
212 params = GetFontRenderParams(query, NULL); | 210 params = GetFontRenderParams(query, NULL); |
213 EXPECT_EQ(FontRenderParams::HINTING_NONE, params.hinting); | 211 EXPECT_EQ(FontRenderParams::HINTING_NONE, params.hinting); |
214 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE, | 212 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE, |
215 params.subpixel_rendering); | 213 params.subpixel_rendering); |
216 } | 214 } |
217 | 215 |
218 TEST_F(FontRenderParamsTest, Scalable) { | 216 TEST_F(FontRenderParamsTest, Scalable) { |
219 // Load a config that only enables antialiasing for scalable fonts. | 217 // Load a config that only enables antialiasing for scalable fonts. |
220 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 218 ASSERT_TRUE(LoadConfigDataIntoFontconfig( |
221 std::string(kFontconfigFileHeader) + | 219 temp_dir_.GetPath(), |
222 kFontconfigMatchPatternHeader + | 220 std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader + |
223 CreateFontconfigEditStanza("antialias", "bool", "false") + | 221 CreateFontconfigEditStanza("antialias", "bool", "false") + |
224 kFontconfigMatchFooter + | 222 kFontconfigMatchFooter + kFontconfigMatchPatternHeader + |
225 kFontconfigMatchPatternHeader + | 223 CreateFontconfigTestStanza("scalable", "eq", "bool", "true") + |
226 CreateFontconfigTestStanza("scalable", "eq", "bool", "true") + | 224 CreateFontconfigEditStanza("antialias", "bool", "true") + |
227 CreateFontconfigEditStanza("antialias", "bool", "true") + | 225 kFontconfigMatchFooter + kFontconfigFileFooter)); |
228 kFontconfigMatchFooter + | |
229 kFontconfigFileFooter)); | |
230 | 226 |
231 // Check that we specifically ask how scalable fonts should be rendered. | 227 // Check that we specifically ask how scalable fonts should be rendered. |
232 FontRenderParams params = GetFontRenderParams( | 228 FontRenderParams params = GetFontRenderParams( |
233 FontRenderParamsQuery(), NULL); | 229 FontRenderParamsQuery(), NULL); |
234 EXPECT_TRUE(params.antialiasing); | 230 EXPECT_TRUE(params.antialiasing); |
235 } | 231 } |
236 | 232 |
237 TEST_F(FontRenderParamsTest, UseBitmaps) { | 233 TEST_F(FontRenderParamsTest, UseBitmaps) { |
238 ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); | 234 ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); |
239 // Load a config that enables embedded bitmaps for fonts <= 10 pixels. | 235 // Load a config that enables embedded bitmaps for fonts <= 10 pixels. |
240 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 236 ASSERT_TRUE(LoadConfigDataIntoFontconfig( |
241 std::string(kFontconfigFileHeader) + | 237 temp_dir_.GetPath(), |
242 kFontconfigMatchPatternHeader + | 238 std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader + |
243 CreateFontconfigEditStanza("embeddedbitmap", "bool", "false") + | 239 CreateFontconfigEditStanza("embeddedbitmap", "bool", "false") + |
244 kFontconfigMatchFooter + | 240 kFontconfigMatchFooter + kFontconfigMatchPatternHeader + |
245 kFontconfigMatchPatternHeader + | 241 CreateFontconfigTestStanza("pixelsize", "less_eq", "double", "10") + |
246 CreateFontconfigTestStanza("pixelsize", "less_eq", "double", "10") + | 242 CreateFontconfigEditStanza("embeddedbitmap", "bool", "true") + |
247 CreateFontconfigEditStanza("embeddedbitmap", "bool", "true") + | 243 kFontconfigMatchFooter + kFontconfigFileFooter)); |
248 kFontconfigMatchFooter + | |
249 kFontconfigFileFooter)); | |
250 | 244 |
251 FontRenderParamsQuery query; | 245 FontRenderParamsQuery query; |
252 FontRenderParams params = GetFontRenderParams(query, NULL); | 246 FontRenderParams params = GetFontRenderParams(query, NULL); |
253 EXPECT_FALSE(params.use_bitmaps); | 247 EXPECT_FALSE(params.use_bitmaps); |
254 | 248 |
255 query.pixel_size = 5; | 249 query.pixel_size = 5; |
256 params = GetFontRenderParams(query, NULL); | 250 params = GetFontRenderParams(query, NULL); |
257 EXPECT_TRUE(params.use_bitmaps); | 251 EXPECT_TRUE(params.use_bitmaps); |
258 } | 252 } |
259 | 253 |
260 TEST_F(FontRenderParamsTest, ForceFullHintingWhenAntialiasingIsDisabled) { | 254 TEST_F(FontRenderParamsTest, ForceFullHintingWhenAntialiasingIsDisabled) { |
261 // Load a config that disables antialiasing and hinting while requesting | 255 // Load a config that disables antialiasing and hinting while requesting |
262 // subpixel rendering. | 256 // subpixel rendering. |
263 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 257 ASSERT_TRUE(LoadConfigDataIntoFontconfig( |
264 std::string(kFontconfigFileHeader) + | 258 temp_dir_.GetPath(), |
265 kFontconfigMatchPatternHeader + | 259 std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader + |
266 CreateFontconfigEditStanza("antialias", "bool", "false") + | 260 CreateFontconfigEditStanza("antialias", "bool", "false") + |
267 CreateFontconfigEditStanza("hinting", "bool", "false") + | 261 CreateFontconfigEditStanza("hinting", "bool", "false") + |
268 CreateFontconfigEditStanza("hintstyle", "const", "hintnone") + | 262 CreateFontconfigEditStanza("hintstyle", "const", "hintnone") + |
269 CreateFontconfigEditStanza("rgba", "const", "rgb") + | 263 CreateFontconfigEditStanza("rgba", "const", "rgb") + |
270 kFontconfigMatchFooter + | 264 kFontconfigMatchFooter + kFontconfigFileFooter)); |
271 kFontconfigFileFooter)); | |
272 | 265 |
273 // Full hinting should be forced. See the comment in GetFontRenderParams() for | 266 // Full hinting should be forced. See the comment in GetFontRenderParams() for |
274 // more information. | 267 // more information. |
275 FontRenderParams params = GetFontRenderParams( | 268 FontRenderParams params = GetFontRenderParams( |
276 FontRenderParamsQuery(), NULL); | 269 FontRenderParamsQuery(), NULL); |
277 EXPECT_FALSE(params.antialiasing); | 270 EXPECT_FALSE(params.antialiasing); |
278 EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting); | 271 EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting); |
279 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE, | 272 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE, |
280 params.subpixel_rendering); | 273 params.subpixel_rendering); |
281 EXPECT_FALSE(params.subpixel_positioning); | 274 EXPECT_FALSE(params.subpixel_positioning); |
(...skipping 21 matching lines...) Expand all Loading... |
303 | 296 |
304 TEST_F(FontRenderParamsTest, OnlySetConfiguredValues) { | 297 TEST_F(FontRenderParamsTest, OnlySetConfiguredValues) { |
305 // Configure the LinuxFontDelegate (which queries GtkSettings on desktop | 298 // Configure the LinuxFontDelegate (which queries GtkSettings on desktop |
306 // Linux) to request subpixel rendering. | 299 // Linux) to request subpixel rendering. |
307 FontRenderParams system_params; | 300 FontRenderParams system_params; |
308 system_params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB; | 301 system_params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB; |
309 test_font_delegate_.set_params(system_params); | 302 test_font_delegate_.set_params(system_params); |
310 | 303 |
311 // Load a Fontconfig config that enables antialiasing but doesn't say anything | 304 // Load a Fontconfig config that enables antialiasing but doesn't say anything |
312 // about subpixel rendering. | 305 // about subpixel rendering. |
313 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 306 ASSERT_TRUE(LoadConfigDataIntoFontconfig( |
314 std::string(kFontconfigFileHeader) + | 307 temp_dir_.GetPath(), |
315 kFontconfigMatchPatternHeader + | 308 std::string(kFontconfigFileHeader) + kFontconfigMatchPatternHeader + |
316 CreateFontconfigEditStanza("antialias", "bool", "true") + | 309 CreateFontconfigEditStanza("antialias", "bool", "true") + |
317 kFontconfigMatchFooter + | 310 kFontconfigMatchFooter + kFontconfigFileFooter)); |
318 kFontconfigFileFooter)); | |
319 | 311 |
320 // The subpixel rendering setting from the delegate should make it through. | 312 // The subpixel rendering setting from the delegate should make it through. |
321 FontRenderParams params = GetFontRenderParams( | 313 FontRenderParams params = GetFontRenderParams( |
322 FontRenderParamsQuery(), NULL); | 314 FontRenderParamsQuery(), NULL); |
323 EXPECT_EQ(system_params.subpixel_rendering, params.subpixel_rendering); | 315 EXPECT_EQ(system_params.subpixel_rendering, params.subpixel_rendering); |
324 } | 316 } |
325 | 317 |
326 TEST_F(FontRenderParamsTest, NoFontconfigMatch) { | 318 TEST_F(FontRenderParamsTest, NoFontconfigMatch) { |
327 // Don't load a Fontconfig configuration. | 319 // Don't load a Fontconfig configuration. |
328 FontRenderParams system_params; | 320 FontRenderParams system_params; |
(...skipping 27 matching lines...) Expand all Loading... |
356 query.families.push_back("Verdana"); | 348 query.families.push_back("Verdana"); |
357 std::string suggested_family; | 349 std::string suggested_family; |
358 GetFontRenderParams(query, &suggested_family); | 350 GetFontRenderParams(query, &suggested_family); |
359 EXPECT_EQ("Arial", suggested_family); | 351 EXPECT_EQ("Arial", suggested_family); |
360 } | 352 } |
361 | 353 |
362 TEST_F(FontRenderParamsTest, SubstituteFamily) { | 354 TEST_F(FontRenderParamsTest, SubstituteFamily) { |
363 // Configure Fontconfig to use Verdana for both Helvetica and Arial. | 355 // Configure Fontconfig to use Verdana for both Helvetica and Arial. |
364 ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); | 356 ASSERT_TRUE(LoadSystemFontIntoFontconfig("arial.ttf")); |
365 ASSERT_TRUE(LoadSystemFontIntoFontconfig("verdana.ttf")); | 357 ASSERT_TRUE(LoadSystemFontIntoFontconfig("verdana.ttf")); |
366 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 358 ASSERT_TRUE(LoadConfigDataIntoFontconfig( |
| 359 temp_dir_.GetPath(), |
367 std::string(kFontconfigFileHeader) + | 360 std::string(kFontconfigFileHeader) + |
368 CreateFontconfigAliasStanza("Helvetica", "Verdana") + | 361 CreateFontconfigAliasStanza("Helvetica", "Verdana") + |
369 kFontconfigMatchPatternHeader + | 362 kFontconfigMatchPatternHeader + |
370 CreateFontconfigTestStanza("family", "eq", "string", "Arial") + | 363 CreateFontconfigTestStanza("family", "eq", "string", "Arial") + |
371 CreateFontconfigEditStanza("family", "string", "Verdana") + | 364 CreateFontconfigEditStanza("family", "string", "Verdana") + |
372 kFontconfigMatchFooter + | 365 kFontconfigMatchFooter + kFontconfigFileFooter)); |
373 kFontconfigFileFooter)); | |
374 | 366 |
375 FontRenderParamsQuery query; | 367 FontRenderParamsQuery query; |
376 query.families.push_back("Helvetica"); | 368 query.families.push_back("Helvetica"); |
377 std::string suggested_family; | 369 std::string suggested_family; |
378 GetFontRenderParams(query, &suggested_family); | 370 GetFontRenderParams(query, &suggested_family); |
379 EXPECT_EQ("Verdana", suggested_family); | 371 EXPECT_EQ("Verdana", suggested_family); |
380 | 372 |
381 query.families.clear(); | 373 query.families.clear(); |
382 query.families.push_back("Arial"); | 374 query.families.push_back("Arial"); |
383 suggested_family.clear(); | 375 suggested_family.clear(); |
384 GetFontRenderParams(query, &suggested_family); | 376 GetFontRenderParams(query, &suggested_family); |
385 EXPECT_EQ("Verdana", suggested_family); | 377 EXPECT_EQ("Verdana", suggested_family); |
386 } | 378 } |
387 | 379 |
388 } // namespace gfx | 380 } // namespace gfx |
OLD | NEW |