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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 ASSERT_TRUE(LoadSystemFont("arial.ttf")); | 89 ASSERT_TRUE(LoadSystemFont("arial.ttf")); |
90 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 90 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), |
91 std::string(kFontconfigFileHeader) + | 91 std::string(kFontconfigFileHeader) + |
92 kFontconfigMatchPatternHeader + | 92 kFontconfigMatchPatternHeader + |
93 CreateFontconfigEditStanza("antialias", "bool", "true") + | 93 CreateFontconfigEditStanza("antialias", "bool", "true") + |
94 CreateFontconfigEditStanza("autohint", "bool", "true") + | 94 CreateFontconfigEditStanza("autohint", "bool", "true") + |
95 CreateFontconfigEditStanza("hinting", "bool", "true") + | 95 CreateFontconfigEditStanza("hinting", "bool", "true") + |
96 CreateFontconfigEditStanza("hintstyle", "const", "hintslight") + | 96 CreateFontconfigEditStanza("hintstyle", "const", "hintslight") + |
97 CreateFontconfigEditStanza("rgba", "const", "rgb") + | 97 CreateFontconfigEditStanza("rgba", "const", "rgb") + |
98 kFontconfigMatchFooter + | 98 kFontconfigMatchFooter + |
99 // Add a font match for Arial; it shouldn't be used when querying for | 99 // Add a font match for Arial; it shouldn't be used on Chrome OS but when |
100 // default settings: http://crbug.com/421247 | 100 // querying for default settings: http://crbug.com/421247 |
101 // | |
102 // The match _should_ take affect on desktop Linux, though: | |
msw
2014/12/17 22:42:23
nit: "take effect"
Daniel Erat
2014/12/18 00:15:46
oh my, that's embarrassing. i know the difference
| |
103 // http://crbug.com/442443 | |
101 kFontconfigMatchFontHeader + | 104 kFontconfigMatchFontHeader + |
102 CreateFontconfigTestStanza("family", "eq", "string", "Arial") + | 105 CreateFontconfigTestStanza("family", "eq", "string", "Arial") + |
103 CreateFontconfigEditStanza("antialias", "bool", "true") + | 106 CreateFontconfigEditStanza("antialias", "bool", "true") + |
104 CreateFontconfigEditStanza("autohint", "bool", "false") + | 107 CreateFontconfigEditStanza("autohint", "bool", "false") + |
105 CreateFontconfigEditStanza("hinting", "bool", "true") + | 108 CreateFontconfigEditStanza("hinting", "bool", "true") + |
106 CreateFontconfigEditStanza("hintstyle", "const", "hintfull") + | 109 CreateFontconfigEditStanza("hintstyle", "const", "hintfull") + |
107 kFontconfigMatchFooter + | 110 kFontconfigMatchFooter + |
108 kFontconfigFileFooter)); | 111 kFontconfigFileFooter)); |
109 | 112 |
110 FontRenderParams params = GetFontRenderParams( | 113 FontRenderParams params = GetFontRenderParams( |
111 FontRenderParamsQuery(true), NULL); | 114 FontRenderParamsQuery(true), NULL); |
112 EXPECT_TRUE(params.antialiasing); | 115 EXPECT_TRUE(params.antialiasing); |
116 EXPECT_TRUE(params.use_bitmaps); | |
117 #if defined(OS_CHROMEOS) | |
113 EXPECT_TRUE(params.autohinter); | 118 EXPECT_TRUE(params.autohinter); |
114 EXPECT_TRUE(params.use_bitmaps); | |
115 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); | 119 EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting); |
120 #else | |
121 EXPECT_FALSE(params.autohinter); | |
122 EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting); | |
123 #endif | |
116 EXPECT_FALSE(params.subpixel_positioning); | 124 EXPECT_FALSE(params.subpixel_positioning); |
117 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB, | 125 EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB, |
118 params.subpixel_rendering); | 126 params.subpixel_rendering); |
119 } | 127 } |
120 | 128 |
121 TEST_F(FontRenderParamsTest, Size) { | 129 TEST_F(FontRenderParamsTest, Size) { |
122 ASSERT_TRUE(LoadSystemFont("arial.ttf")); | 130 ASSERT_TRUE(LoadSystemFont("arial.ttf")); |
123 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 131 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), |
124 std::string(kFontconfigFileHeader) + | 132 std::string(kFontconfigFileHeader) + |
125 kFontconfigMatchPatternHeader + | 133 kFontconfigMatchPatternHeader + |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 FontRenderParamsQuery query(false); | 257 FontRenderParamsQuery query(false); |
250 FontRenderParams params = GetFontRenderParams(query, NULL); | 258 FontRenderParams params = GetFontRenderParams(query, NULL); |
251 EXPECT_FALSE(params.use_bitmaps); | 259 EXPECT_FALSE(params.use_bitmaps); |
252 | 260 |
253 query.pixel_size = 5; | 261 query.pixel_size = 5; |
254 params = GetFontRenderParams(query, NULL); | 262 params = GetFontRenderParams(query, NULL); |
255 EXPECT_TRUE(params.use_bitmaps); | 263 EXPECT_TRUE(params.use_bitmaps); |
256 } | 264 } |
257 | 265 |
258 TEST_F(FontRenderParamsTest, ForceFullHintingWhenAntialiasingIsDisabled) { | 266 TEST_F(FontRenderParamsTest, ForceFullHintingWhenAntialiasingIsDisabled) { |
267 #if !defined(OS_CHROMEOS) | |
268 ASSERT_TRUE(LoadSystemFont("arial.ttf")); | |
269 #endif | |
259 // Load a config that disables antialiasing and hinting while requesting | 270 // Load a config that disables antialiasing and hinting while requesting |
260 // subpixel rendering. | 271 // subpixel rendering. |
261 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), | 272 ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(), |
262 std::string(kFontconfigFileHeader) + | 273 std::string(kFontconfigFileHeader) + |
274 #if defined(OS_CHROMEOS) | |
263 kFontconfigMatchPatternHeader + | 275 kFontconfigMatchPatternHeader + |
276 #else | |
277 // Desktop Linux performs a match instead of using the default pattern. | |
msw
2014/12/17 22:42:23
Shouldn't Linux fall back on the default pattern i
Daniel Erat
2014/12/18 00:15:46
that's what i was thinking at first, but i saw fai
| |
278 kFontconfigMatchFontHeader + | |
279 #endif | |
264 CreateFontconfigEditStanza("antialias", "bool", "false") + | 280 CreateFontconfigEditStanza("antialias", "bool", "false") + |
265 CreateFontconfigEditStanza("hinting", "bool", "false") + | 281 CreateFontconfigEditStanza("hinting", "bool", "false") + |
266 CreateFontconfigEditStanza("hintstyle", "const", "hintnone") + | 282 CreateFontconfigEditStanza("hintstyle", "const", "hintnone") + |
267 CreateFontconfigEditStanza("rgba", "const", "rgb") + | 283 CreateFontconfigEditStanza("rgba", "const", "rgb") + |
268 kFontconfigMatchFooter + | 284 kFontconfigMatchFooter + |
269 kFontconfigFileFooter)); | 285 kFontconfigFileFooter)); |
270 | 286 |
271 // Full hinting should be forced. See the comment in GetFontRenderParams() for | 287 // Full hinting should be forced. See the comment in GetFontRenderParams() for |
272 // more information. | 288 // more information. |
273 FontRenderParams params = GetFontRenderParams( | 289 FontRenderParams params = GetFontRenderParams( |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 EXPECT_EQ("Verdana", suggested_family); | 395 EXPECT_EQ("Verdana", suggested_family); |
380 | 396 |
381 query.families.clear(); | 397 query.families.clear(); |
382 query.families.push_back("Arial"); | 398 query.families.push_back("Arial"); |
383 suggested_family.clear(); | 399 suggested_family.clear(); |
384 GetFontRenderParams(query, &suggested_family); | 400 GetFontRenderParams(query, &suggested_family); |
385 EXPECT_EQ("Verdana", suggested_family); | 401 EXPECT_EQ("Verdana", suggested_family); |
386 } | 402 } |
387 | 403 |
388 } // namespace gfx | 404 } // namespace gfx |
OLD | NEW |