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 #if defined(OS_CHROMEOS) |
| 277 TEST_F(FontRenderParamsTest, ForceSubpixelPositioning) { |
| 278 { |
| 279 FontRenderParams params = |
| 280 GetFontRenderParams(FontRenderParamsQuery(false), NULL); |
| 281 EXPECT_TRUE(params.antialiasing); |
| 282 EXPECT_FALSE(params.subpixel_positioning); |
| 283 SetFontRenderParamsDeviceScaleFactor(1.0f); |
| 284 } |
| 285 ClearFontRenderParamsCacheForTest(); |
| 286 SetFontRenderParamsDeviceScaleFactor(1.25f); |
| 287 // Subpixel positioning should be forced. |
| 288 { |
| 289 FontRenderParams params = |
| 290 GetFontRenderParams(FontRenderParamsQuery(false), NULL); |
| 291 EXPECT_TRUE(params.antialiasing); |
| 292 EXPECT_TRUE(params.subpixel_positioning); |
| 293 SetFontRenderParamsDeviceScaleFactor(1.0f); |
| 294 } |
| 295 } |
| 296 #endif |
| 297 |
276 TEST_F(FontRenderParamsTest, OnlySetConfiguredValues) { | 298 TEST_F(FontRenderParamsTest, OnlySetConfiguredValues) { |
277 // Configure the LinuxFontDelegate (which queries GtkSettings on desktop | 299 // Configure the LinuxFontDelegate (which queries GtkSettings on desktop |
278 // Linux) to request subpixel rendering. | 300 // Linux) to request subpixel rendering. |
279 FontRenderParams system_params; | 301 FontRenderParams system_params; |
280 system_params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB; | 302 system_params.subpixel_rendering = FontRenderParams::SUBPIXEL_RENDERING_RGB; |
281 test_font_delegate_.set_params(system_params); | 303 test_font_delegate_.set_params(system_params); |
282 | 304 |
283 // Load a Fontconfig config that enables antialiasing but doesn't say anything | 305 // Load a Fontconfig config that enables antialiasing but doesn't say anything |
284 // about subpixel rendering. | 306 // about subpixel rendering. |
285 ASSERT_TRUE(LoadSystemFont("arial.ttf")); | 307 ASSERT_TRUE(LoadSystemFont("arial.ttf")); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 EXPECT_EQ("Verdana", suggested_family); | 374 EXPECT_EQ("Verdana", suggested_family); |
353 | 375 |
354 query.families.clear(); | 376 query.families.clear(); |
355 query.families.push_back("Arial"); | 377 query.families.push_back("Arial"); |
356 suggested_family.clear(); | 378 suggested_family.clear(); |
357 GetFontRenderParams(query, &suggested_family); | 379 GetFontRenderParams(query, &suggested_family); |
358 EXPECT_EQ("Verdana", suggested_family); | 380 EXPECT_EQ("Verdana", suggested_family); |
359 } | 381 } |
360 | 382 |
361 } // namespace gfx | 383 } // namespace gfx |
OLD | NEW |