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

Unified Diff: ui/gfx/font_render_params_linux_unittest.cc

Issue 417003002: linux: Force full hinting when antialiasing is disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix a comment Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/font_render_params_linux_unittest.cc
diff --git a/ui/gfx/font_render_params_linux_unittest.cc b/ui/gfx/font_render_params_linux_unittest.cc
index a7924833234db3646a4808c978e956041878191d..a473f34cce41420814560cb620cffd528703ccbc 100644
--- a/ui/gfx/font_render_params_linux_unittest.cc
+++ b/ui/gfx/font_render_params_linux_unittest.cc
@@ -158,18 +158,19 @@ TEST_F(FontRenderParamsTest, Size) {
TEST_F(FontRenderParamsTest, Style) {
ASSERT_TRUE(LoadSystemFont("arial.ttf"));
- // Load a config that disables antialiasing for bold text and disables
+ // Load a config that disables subpixel rendering for bold text and disables
// hinting for italic text.
ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
std::string(kFontconfigFileHeader) +
kFontconfigMatchHeader +
CreateFontconfigEditStanza("antialias", "bool", "true") +
CreateFontconfigEditStanza("hinting", "bool", "true") +
- CreateFontconfigEditStanza("hintstyle", "const", "hintfull") +
+ CreateFontconfigEditStanza("hintstyle", "const", "hintslight") +
+ CreateFontconfigEditStanza("rgba", "const", "rgb") +
kFontconfigMatchFooter +
kFontconfigMatchHeader +
CreateFontconfigTestStanza("weight", "eq", "const", "bold") +
- CreateFontconfigEditStanza("antialias", "bool", "false") +
+ CreateFontconfigEditStanza("rgba", "const", "none") +
kFontconfigMatchFooter +
kFontconfigMatchHeader +
CreateFontconfigTestStanza("slant", "eq", "const", "italic") +
@@ -180,23 +181,27 @@ TEST_F(FontRenderParamsTest, Style) {
FontRenderParamsQuery query(false);
query.style = Font::NORMAL;
FontRenderParams params = GetFontRenderParams(query, NULL);
- EXPECT_TRUE(params.antialiasing);
- EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting);
+ EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting);
+ EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB,
+ params.subpixel_rendering);
query.style = Font::BOLD;
params = GetFontRenderParams(query, NULL);
- EXPECT_FALSE(params.antialiasing);
- EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting);
+ EXPECT_EQ(FontRenderParams::HINTING_SLIGHT, params.hinting);
+ EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE,
+ params.subpixel_rendering);
query.style = Font::ITALIC;
params = GetFontRenderParams(query, NULL);
- EXPECT_TRUE(params.antialiasing);
EXPECT_EQ(FontRenderParams::HINTING_NONE, params.hinting);
+ EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_RGB,
+ params.subpixel_rendering);
query.style = Font::BOLD | Font::ITALIC;
params = GetFontRenderParams(query, NULL);
- EXPECT_FALSE(params.antialiasing);
EXPECT_EQ(FontRenderParams::HINTING_NONE, params.hinting);
+ EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE,
+ params.subpixel_rendering);
}
TEST_F(FontRenderParamsTest, Scalable) {
@@ -242,6 +247,31 @@ TEST_F(FontRenderParamsTest, UseBitmaps) {
EXPECT_TRUE(params.use_bitmaps);
}
+TEST_F(FontRenderParamsTest, ForceFullHintingWhenAntialiasingIsDisabled) {
+ // Load a config that disables antialiasing and hinting while requesting
+ // subpixel rendering.
+ ASSERT_TRUE(LoadSystemFont("arial.ttf"));
+ ASSERT_TRUE(LoadConfigDataIntoFontconfig(temp_dir_.path(),
+ std::string(kFontconfigFileHeader) +
+ kFontconfigMatchHeader +
+ CreateFontconfigEditStanza("antialias", "bool", "false") +
+ CreateFontconfigEditStanza("hinting", "bool", "false") +
+ CreateFontconfigEditStanza("hintstyle", "const", "hintnone") +
+ CreateFontconfigEditStanza("rgba", "const", "rgb") +
+ kFontconfigMatchFooter +
+ kFontconfigFileFooter));
+
+ // Full hinting should be forced. See the comment in GetFontRenderParams() for
+ // more information.
+ FontRenderParams params = GetFontRenderParams(
+ FontRenderParamsQuery(false), NULL);
+ EXPECT_FALSE(params.antialiasing);
+ EXPECT_EQ(FontRenderParams::HINTING_FULL, params.hinting);
+ EXPECT_EQ(FontRenderParams::SUBPIXEL_RENDERING_NONE,
+ params.subpixel_rendering);
+ EXPECT_FALSE(params.subpixel_positioning);
+}
+
TEST_F(FontRenderParamsTest, OnlySetConfiguredValues) {
// Configure the LinuxFontDelegate (which queries GtkSettings on desktop
// Linux) to request subpixel rendering.
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698