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/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 // more information. | 266 // more information. |
267 FontRenderParams params = GetFontRenderParams( | 267 FontRenderParams params = GetFontRenderParams( |
268 FontRenderParamsQuery(false), NULL); | 268 FontRenderParamsQuery(false), NULL); |
269 EXPECT_FALSE(params.antialiasing); | 269 EXPECT_FALSE(params.antialiasing); |
270 EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting); | 270 EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting); |
271 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE, | 271 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE, |
272 params.subpixel_rendering); | 272 params.subpixel_rendering); |
273 EXPECT_FALSE(params.subpixel_positioning); | 273 EXPECT_FALSE(params.subpixel_positioning); |
274 } | 274 } |
275 | 275 |
276 TEST_F(FontRenderParamsTest, ForceSubpixelPositioning) { | |
Daniel Erat
2014/08/19 22:32:25
this should only be for OS_CHROMEOS, right?
oshima
2014/08/20 01:41:13
Done.
| |
277 // Load a config that disables antialiasing and hinting while requesting | |
278 // subpixel rendering. | |
279 ASSERT_TRUE(LoadSystemFont("arial.ttf")); | |
280 ASSERT_TRUE(LoadConfigDataIntoFontconfig( | |
281 temp_dir_.path(), | |
282 std::string(kFontconfigFileHeader) + kFontconfigMatchHeader + | |
283 CreateFontconfigEditStanza("rgba", "const", "rgb") + | |
Daniel Erat
2014/08/19 22:32:25
do you need this? it seems to be outside the scope
oshima
2014/08/20 01:41:13
Done.
| |
284 kFontconfigMatchFooter + kFontconfigFileFooter)); | |
285 SetDeviceScaleFactorForInternalDisplay(1.25f); | |
286 // Full hinting should be forced. See the comment in GetFontRenderParams() for | |
287 // more information. | |
Daniel Erat
2014/08/19 22:32:25
this comment seems wrong
oshima
2014/08/20 01:41:13
Done.
| |
288 FontRenderParams params = | |
289 GetFontRenderParams(FontRenderParamsQuery(false), NULL); | |
290 EXPECT_TRUE(params.antialiasing); | |
291 EXPECT_TRUE(params.subpixel_positioning); | |
292 SetDeviceScaleFactorForInternalDisplay(1.0f); | |
Daniel Erat
2014/08/19 22:32:25
what's the reason for this? note that the cache ge
oshima
2014/08/20 01:41:13
This is necessary so that other test does not use
| |
293 } | |
294 | |
276 TEST_F(FontRenderParamsTest, OnlySetConfiguredValues) { | 295 TEST_F(FontRenderParamsTest, OnlySetConfiguredValues) { |
277 // Configure the LinuxFontDelegate (which queries GtkSettings on desktop | 296 // Configure the LinuxFontDelegate (which queries GtkSettings on desktop |
278 // Linux) to request subpixel rendering. | 297 // Linux) to request subpixel rendering. |
279 FontRenderParams system_params; | 298 FontRenderParams system_params; |
280 system_params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB; | 299 system_params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB; |
281 test_font_delegate_.set_params(system_params); | 300 test_font_delegate_.set_params(system_params); |
282 | 301 |
283 // Load a Fontconfig config that enables antialiasing but doesn't say anything | 302 // Load a Fontconfig config that enables antialiasing but doesn't say anything |
284 // about subpixel rendering. | 303 // about subpixel rendering. |
285 ASSERT_TRUE(LoadSystemFont("arial.ttf")); | 304 ASSERT_TRUE(LoadSystemFont("arial.ttf")); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 EXPECT_EQ("Verdana", suggested_family); | 371 EXPECT_EQ("Verdana", suggested_family); |
353 | 372 |
354 query.families.clear(); | 373 query.families.clear(); |
355 query.families.push_back("Arial"); | 374 query.families.push_back("Arial"); |
356 suggested_family.clear(); | 375 suggested_family.clear(); |
357 GetFontRenderParams(query, &suggested_family); | 376 GetFontRenderParams(query, &suggested_family); |
358 EXPECT_EQ("Verdana", suggested_family); | 377 EXPECT_EQ("Verdana", suggested_family); |
359 } | 378 } |
360 | 379 |
361 } // namespace gfx | 380 } // namespace gfx |
OLD | NEW |