Source/WebCore: Make Skia backend honor requests for subpixel-positioned text.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2012 16:58:43 +0000 (16:58 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Jun 2012 16:58:43 +0000 (16:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=88263

Patch by Daniel Erat <derat@chromium.org> on 2012-06-07
Reviewed by Tony Chang.

Add subpixel positioning field to FontRenderStyle and rename
subpixel rendering field.

Pass setting to SkPaint in FontPlatformDataHarfBuzz and remove
round() call when computing glyph widths in SimpleFontDataSkia.

Test: platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning.html

* platform/graphics/blackberry/skia/PlatformSupport.cpp:
(WebCore::setFontRenderStyleDefaults):
(WebCore::PlatformSupport::getRenderStyleForStrike):
* platform/graphics/chromium/FontRenderStyle.h:
(WebCore::FontRenderStyle::FontRenderStyle):
(WebCore::FontRenderStyle::operator==):
(FontRenderStyle):
* platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp:
(WebCore):
(WebCore::FontPlatformData::setSubpixelRendering):
(WebCore::FontPlatformData::setSubpixelPositioning):
(WebCore::FontPlatformData::setupPaint):
(WebCore::FontPlatformData::querySystemForRenderStyle):
* platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h:
(FontPlatformData):
* platform/graphics/skia/SimpleFontDataSkia.cpp:
(WebCore::SimpleFontData::platformWidthForGlyph):

Source/WebKit/chromium: Add setting to enable subpixel-positioned text on Linux.
https://bugs.webkit.org/show_bug.cgi?id=88263

Patch by Daniel Erat <derat@chromium.org> on 2012-06-07
Reviewed by Tony Chang.

Add subpixel positioning field to WebFontRenderStyle and rename
subpixel rendering field.  Make similar changes in
WebFontRendering.

Also add global WebFontInfo::setSubpixelPositioning() to turn
subpixel positioning on or off (there's not currently a
well-defined way to configure subpixel positioning via FontConfig).

* public/linux/WebFontInfo.h:
(WebFontInfo):
* public/linux/WebFontRenderStyle.h:
* public/linux/WebFontRendering.h:
(WebFontRendering):
* src/linux/WebFontInfo.cpp:
(WebKit):
(WebKit::WebFontInfo::setSubpixelPositioning):
(WebKit::WebFontInfo::renderStyleForStrike):
* src/linux/WebFontRenderStyle.cpp:
(WebKit::WebFontRenderStyle::toFontRenderStyle):
(WebKit::WebFontRenderStyle::setDefaults):
* src/linux/WebFontRendering.cpp:
(WebKit::WebFontRendering::setSubpixelGlyphs):
(WebKit):
(WebKit::WebFontRendering::setSubpixelRendering):
(WebKit::WebFontRendering::setSubpixelPositioning):

Tools: [chromium] Add LayoutTestController::setTextSubpixelPositioning() for Linux.
https://bugs.webkit.org/show_bug.cgi?id=88263

Patch by Daniel Erat <derat@chromium.org> on 2012-06-07
Reviewed by Tony Chang.

* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController):
(LayoutTestController::reset):
(LayoutTestController::setTextSubpixelPositioning):
* DumpRenderTree/chromium/LayoutTestController.h:
(LayoutTestController):
* DumpRenderTree/chromium/fonts.conf:

LayoutTests: [chromium] Add test for subpixel positioning.
https://bugs.webkit.org/show_bug.cgi?id=88263

Patch by Daniel Erat <derat@chromium.org> on 2012-06-07
Reviewed by Tony Chang.

* platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.png: Added.
* platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.txt: Added.
* platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@119732 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/blackberry/skia/PlatformSupport.cpp
Source/WebCore/platform/graphics/chromium/FontRenderStyle.h
Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp
Source/WebCore/platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h
Source/WebCore/platform/graphics/skia/SimpleFontDataSkia.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/linux/WebFontInfo.h
Source/WebKit/chromium/public/linux/WebFontRenderStyle.h
Source/WebKit/chromium/public/linux/WebFontRendering.h
Source/WebKit/chromium/src/linux/WebFontInfo.cpp
Source/WebKit/chromium/src/linux/WebFontRenderStyle.cpp
Source/WebKit/chromium/src/linux/WebFontRendering.cpp
Tools/ChangeLog
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/chromium/LayoutTestController.h
Tools/DumpRenderTree/chromium/fonts.conf

index 5a0843f..25233ef 100644 (file)
@@ -1,3 +1,14 @@
+2012-06-07  Daniel Erat  <derat@chromium.org>
+
+        [chromium] Add test for subpixel positioning.
+        https://bugs.webkit.org/show_bug.cgi?id=88263
+
+        Reviewed by Tony Chang.
+
+        * platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.png: Added.
+        * platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.txt: Added.
+        * platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning.html: Added.
+
 2012-06-07  Simon Pena  <spena@igalia.com>
 
         [GTK] Add baselines for new tests
diff --git a/LayoutTests/platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.png b/LayoutTests/platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.png
new file mode 100644 (file)
index 0000000..323a427
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.png differ
diff --git a/LayoutTests/platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.txt b/LayoutTests/platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning-expected.txt
new file mode 100644 (file)
index 0000000..db683eb
--- /dev/null
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x576
+      RenderBlock {P} at (0,0) size 784x20
+        RenderText {#text} at (0,0) size 617x19
+          text run at (0,0) width 463: "This test requires a Linux build of DumpRenderTree, as it needs to turn "
+          text run at (462,0) width 155: "on subpixel positioning."
+      RenderBlock {P} at (0,36) size 784x40
+        RenderText {#text} at (0,0) size 752x39
+          text run at (0,0) width 364: "This text should be rendered using subpixel positioning. "
+          text run at (363,0) width 97: "Glyphs should "
+          text run at (459,0) width 293: "be placed at non-integral positions, and in the"
+          text run at (0,20) width 183: "following string of repeated "
+          text run at (182,20) width 335: "\"l\" characters, the glyphs should not all be rendered "
+          text run at (516,20) width 175: "identically: llllllllllllllllllllll"
diff --git a/LayoutTests/platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning.html b/LayoutTests/platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning.html
new file mode 100644 (file)
index 0000000..a9366a5
--- /dev/null
@@ -0,0 +1,23 @@
+<html>
+  <!-- Use a fake font family for all of the text that we draw.
+       The setTextSubpixelPositioning() call changes a global text style
+       setting.  It gets reset after we're dumped, but if we run first, our
+       style would be cached and would affect other tests, and if we run after
+       another test, we'd use its cached style and subpixel positioning won't be
+       enabled. -->
+  <body style="font-family:SubpixelPositioning">
+    <script>
+      if (window.layoutTestController) {
+          layoutTestController.setTextSubpixelPositioning(true);
+      }
+    </script>
+
+    <p>This test requires a Linux build of DumpRenderTree, as it needs to turn
+    on subpixel positioning.</p>
+
+    <p>This text should be rendered using subpixel positioning.  Glyphs should
+    be placed at non-integral positions, and in the following string of repeated
+    &quot;l&quot; characters, the glyphs should not all be rendered
+    identically: llllllllllllllllllllll</p>
+  </body>
+</html>
index 67ffb0d..5baf51f 100644 (file)
@@ -1,3 +1,36 @@
+2012-06-07  Daniel Erat  <derat@chromium.org>
+
+        Make Skia backend honor requests for subpixel-positioned text.
+        https://bugs.webkit.org/show_bug.cgi?id=88263
+
+        Reviewed by Tony Chang.
+
+        Add subpixel positioning field to FontRenderStyle and rename
+        subpixel rendering field.
+
+        Pass setting to SkPaint in FontPlatformDataHarfBuzz and remove
+        round() call when computing glyph widths in SimpleFontDataSkia.
+
+        Test: platform/chromium-linux/fast/text/chromium-linux-text-subpixel-positioning.html
+
+        * platform/graphics/blackberry/skia/PlatformSupport.cpp:
+        (WebCore::setFontRenderStyleDefaults):
+        (WebCore::PlatformSupport::getRenderStyleForStrike):
+        * platform/graphics/chromium/FontRenderStyle.h:
+        (WebCore::FontRenderStyle::FontRenderStyle):
+        (WebCore::FontRenderStyle::operator==):
+        (FontRenderStyle):
+        * platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.cpp:
+        (WebCore):
+        (WebCore::FontPlatformData::setSubpixelRendering):
+        (WebCore::FontPlatformData::setSubpixelPositioning):
+        (WebCore::FontPlatformData::setupPaint):
+        (WebCore::FontPlatformData::querySystemForRenderStyle):
+        * platform/graphics/harfbuzz/FontPlatformDataHarfBuzz.h:
+        (FontPlatformData):
+        * platform/graphics/skia/SimpleFontDataSkia.cpp:
+        (WebCore::SimpleFontData::platformWidthForGlyph):
+
 2012-06-06  Dana Jansens  <danakj@chromium.org>
 
         [chromium] In each composited frame, didDraw() should only be called on layers for which willDraw() was called
index 408fe45..d4e5eba 100644 (file)
@@ -48,7 +48,7 @@ static void setFontRenderStyleDefaults(FontRenderStyle* style)
     style->useHinting = 2;
     style->hintStyle = 0;
     style->useAntiAlias = 2;
-    style->useSubpixel = 2;
+    style->useSubpixelRendering = 2;
 }
 
 void PlatformSupport::getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* out)
@@ -111,17 +111,17 @@ void PlatformSupport::getRenderStyleForStrike(const char* family, int sizeAndSty
     if (FcPatternGetInteger(match, FC_RGBA, 0, &intValue) == FcResultMatch) {
         switch (intValue) {
         case FC_RGBA_NONE:
-            out->useSubpixel = 0;
+            out->useSubpixelRendering = 0;
             break;
         case FC_RGBA_RGB:
         case FC_RGBA_BGR:
         case FC_RGBA_VRGB:
         case FC_RGBA_VBGR:
-            out->useSubpixel = 1;
+            out->useSubpixelRendering = 1;
             break;
         default:
             // This includes FC_RGBA_UNKNOWN.
-            out->useSubpixel = 2;
+            out->useSubpixelRendering = 2;
             break;
         }
     }
index 6e2ae54..e44abb4 100644 (file)
@@ -40,12 +40,13 @@ struct FontRenderStyle {
     };
 
     FontRenderStyle()
-        : useBitmaps(0),
-          useAutoHint(0),
-          useHinting(0),
-          hintStyle(0),
-          useAntiAlias(0),
-          useSubpixel(0) { }
+        : useBitmaps(0)
+        , useAutoHint(0)
+        , useHinting(0)
+        , hintStyle(0)
+        , useAntiAlias(0)
+        , useSubpixelRendering(0)
+        , useSubpixelPositioning(0) { }
 
     bool operator==(const FontRenderStyle& a) const
     {
@@ -54,7 +55,8 @@ struct FontRenderStyle {
             && useHinting == a.useHinting
             && hintStyle == a.hintStyle
             && useAntiAlias == a.useAntiAlias
-            && useSubpixel == a.useSubpixel;
+            && useSubpixelRendering == a.useSubpixelRendering
+            && useSubpixelPositioning == a.useSubpixelPositioning;
     }
 
     // Each of the use* members below can take one of three values:
@@ -66,7 +68,8 @@ struct FontRenderStyle {
     char useHinting; // hint glyphs to the pixel grid
     char hintStyle; // level of hinting, 0..3
     char useAntiAlias; // antialias glyph shapes
-    char useSubpixel; // use subpixel antialias
+    char useSubpixelRendering; // use subpixel rendering (partially-filled pixels)
+    char useSubpixelPositioning; // use subpixel positioning (fractional X positions for glyphs)
 };
 
 }
index f8bef5c..9aef046 100644 (file)
@@ -46,7 +46,8 @@ namespace WebCore {
 
 static SkPaint::Hinting skiaHinting = SkPaint::kNormal_Hinting;
 static bool isSkiaAntiAlias = true;
-static bool isSkiaSubpixelGlyphs = false;
+static bool useSkiaSubpixelRendering = false;
+static bool useSkiaSubpixelPositioning = false;
 
 void FontPlatformData::setHinting(SkPaint::Hinting hinting)
 {
@@ -58,9 +59,14 @@ void FontPlatformData::setAntiAlias(bool isAntiAlias)
     isSkiaAntiAlias = isAntiAlias;
 }
 
-void FontPlatformData::setSubpixelGlyphs(bool isSubpixelGlyphs)
+void FontPlatformData::setSubpixelRendering(bool useSubpixelRendering)
 {
-    isSkiaSubpixelGlyphs = isSubpixelGlyphs;
+    useSkiaSubpixelRendering = useSubpixelRendering;
+}
+
+void FontPlatformData::setSubpixelPositioning(bool useSubpixelPositioning)
+{
+    useSkiaSubpixelPositioning = useSubpixelPositioning;
 }
 
 FontPlatformData::FontPlatformData(const FontPlatformData& src)
@@ -178,9 +184,10 @@ void FontPlatformData::setupPaint(SkPaint* paint) const
     paint->setFakeBoldText(m_fakeBold);
     paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1 / 4 : 0);
     paint->setAutohinted(m_style.useAutoHint);
+    paint->setSubpixelText(m_style.useSubpixelPositioning == FontRenderStyle::NoPreference ? useSkiaSubpixelPositioning : m_style.useSubpixelPositioning);
 
     if (m_style.useAntiAlias == 1 || (m_style.useAntiAlias == FontRenderStyle::NoPreference && isSkiaAntiAlias))
-        paint->setLCDRenderText(m_style.useSubpixel == FontRenderStyle::NoPreference ? isSkiaSubpixelGlyphs : m_style.useSubpixel);
+        paint->setLCDRenderText(m_style.useSubpixelRendering == FontRenderStyle::NoPreference ? useSkiaSubpixelRendering : m_style.useSubpixelRendering);
 }
 
 SkFontID FontPlatformData::uniqueID() const
@@ -243,14 +250,14 @@ HarfbuzzFace* FontPlatformData::harfbuzzFace() const
 void FontPlatformData::querySystemForRenderStyle()
 {
     if (!m_family.length()) {
-        // We don't have a family for this. Probably because it's a webfont. We
-        // set all the values to 'no preference' and take the defaults passed
-        // in from XSETTINGS.
+        // We don't have a family for this, probably because it's a webfont. We
+        // set all the values to 'no preference' and take the system defaults.
         m_style.useBitmaps = FontRenderStyle::NoPreference;
         m_style.useAutoHint = FontRenderStyle::NoPreference;
         m_style.useHinting = FontRenderStyle::NoPreference;
         m_style.useAntiAlias = FontRenderStyle::NoPreference;
-        m_style.useSubpixel = FontRenderStyle::NoPreference;
+        m_style.useSubpixelRendering = FontRenderStyle::NoPreference;
+        m_style.useSubpixelPositioning = FontRenderStyle::NoPreference;
         return;
     }
 
index d879f2e..df9bd73 100644 (file)
@@ -134,8 +134,9 @@ public:
     // Global font preferences...
 
     static void setHinting(SkPaint::Hinting);
-    static void setAntiAlias(bool on);
-    static void setSubpixelGlyphs(bool on);
+    static void setAntiAlias(bool);
+    static void setSubpixelRendering(bool);
+    static void setSubpixelPositioning(bool);
 
 private:
     void querySystemForRenderStyle();
index 65a468e..b4d20b0 100644 (file)
@@ -235,11 +235,9 @@ float SimpleFontData::platformWidthForGlyph(Glyph glyph) const
 
     paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
     SkScalar width = paint.measureText(&glyph, 2);
-
-    // Though WebKit supports non-integral advances, Skia only supports them
-    // for "subpixel" (distinct from LCD subpixel antialiasing) text, which
-    // we don't use.
-    return round(SkScalarToFloat(width));
+    if (!paint.isSubpixelText())
+        width = SkScalarRound(width);
+    return SkScalarToFloat(width);
 }
 
 } // namespace WebCore
index 55588d2..075e996 100644 (file)
@@ -1,3 +1,36 @@
+2012-06-07  Daniel Erat  <derat@chromium.org>
+
+        Add setting to enable subpixel-positioned text on Linux.
+        https://bugs.webkit.org/show_bug.cgi?id=88263
+
+        Reviewed by Tony Chang.
+
+        Add subpixel positioning field to WebFontRenderStyle and rename
+        subpixel rendering field.  Make similar changes in
+        WebFontRendering.
+
+        Also add global WebFontInfo::setSubpixelPositioning() to turn
+        subpixel positioning on or off (there's not currently a
+        well-defined way to configure subpixel positioning via FontConfig).
+
+        * public/linux/WebFontInfo.h:
+        (WebFontInfo):
+        * public/linux/WebFontRenderStyle.h:
+        * public/linux/WebFontRendering.h:
+        (WebFontRendering):
+        * src/linux/WebFontInfo.cpp:
+        (WebKit):
+        (WebKit::WebFontInfo::setSubpixelPositioning):
+        (WebKit::WebFontInfo::renderStyleForStrike):
+        * src/linux/WebFontRenderStyle.cpp:
+        (WebKit::WebFontRenderStyle::toFontRenderStyle):
+        (WebKit::WebFontRenderStyle::setDefaults):
+        * src/linux/WebFontRendering.cpp:
+        (WebKit::WebFontRendering::setSubpixelGlyphs):
+        (WebKit):
+        (WebKit::WebFontRendering::setSubpixelRendering):
+        (WebKit::WebFontRendering::setSubpixelPositioning):
+
 2012-06-06  Dana Jansens  <danakj@chromium.org>
 
         [chromium] In each composited frame, didDraw() should only be called on layers for which willDraw() was called
index 72e1091..a714c82 100644 (file)
@@ -42,6 +42,11 @@ namespace WebKit {
 
 class WebFontInfo {
 public:
+    // Set a global preference describing whether renderStyleForStrike() should
+    // enable subpixel positioning or not. FontConfig doesn't currently provide
+    // a parameter for controlling this.
+    WEBKIT_EXPORT static void setSubpixelPositioning(bool);
+
     // Return a font family which provides glyphs for the Unicode code points
     // specified by |utf16|
     //   characters: a native-endian UTF16 string
index 9b16380..6c871d8 100644 (file)
@@ -47,7 +47,9 @@ struct WEBKIT_EXPORT WebFontRenderStyle {
     char useHinting; // hint glyphs to the pixel grid
     char hintStyle; // level of hinting, 0..3
     char useAntiAlias; // antialias glyph shapes
-    char useSubpixel; // use subpixel antialias
+    char useSubpixel; // DEPRECATED: replaced by useSubpixelRendering
+    char useSubpixelRendering; // use subpixel rendering (partially-filled pixels)
+    char useSubpixelPositioning; // use subpixel positioning (fractional X positions for glyphs)
 
 #ifdef WEBKIT_IMPLEMENTATION
     // Translates the members of this struct to a FontRenderStyle
index 87a59b8..172d3bd 100644 (file)
@@ -42,8 +42,10 @@ public:
     // Set global font renderering preferences.
 
     WEBKIT_EXPORT static void setHinting(SkPaint::Hinting);
-    WEBKIT_EXPORT static void setAntiAlias(bool on);
-    WEBKIT_EXPORT static void setSubpixelGlyphs(bool on);
+    WEBKIT_EXPORT static void setAntiAlias(bool);
+    WEBKIT_EXPORT static void setSubpixelGlyphs(bool); // DEPRECATED: use setSubpixelRendering instead
+    WEBKIT_EXPORT static void setSubpixelRendering(bool);
+    WEBKIT_EXPORT static void setSubpixelPositioning(bool);
     WEBKIT_EXPORT static void setLCDOrder(SkFontHost::LCDOrder);
     WEBKIT_EXPORT static void setLCDOrientation(SkFontHost::LCDOrientation);
 };
index b23b777..2bcc83e 100644 (file)
 
 namespace WebKit {
 
+static bool useSubpixelPositioning = false;
+
+void WebFontInfo::setSubpixelPositioning(bool subpixelPositioning)
+{
+    useSubpixelPositioning = subpixelPositioning;
+}
+
 void WebFontInfo::familyForChars(const WebUChar* characters, size_t numCharacters, const char* preferredLocale, WebFontFamily* family)
 {
     FcCharSet* cset = FcCharSetCreate();
@@ -186,20 +193,27 @@ void WebFontInfo::renderStyleForStrike(const char* family, int sizeAndStyle, Web
         switch (i) {
         case FC_RGBA_NONE:
             out->useSubpixel = 0;
+            out->useSubpixelRendering = 0;
             break;
         case FC_RGBA_RGB:
         case FC_RGBA_BGR:
         case FC_RGBA_VRGB:
         case FC_RGBA_VBGR:
             out->useSubpixel = 1;
+            out->useSubpixelRendering = 1;
             break;
         default:
             // This includes FC_RGBA_UNKNOWN.
             out->useSubpixel = 2;
+            out->useSubpixelRendering = 2;
             break;
         }
     }
 
+    // FontConfig doesn't provide parameters to configure whether subpixel
+    // positioning should be used or not, so we just use a global setting.
+    out->useSubpixelPositioning = useSubpixelPositioning;
+
     FcPatternDestroy(match);
 }
 
index 0b864d1..4294c50 100644 (file)
@@ -44,7 +44,8 @@ void WebFontRenderStyle::toFontRenderStyle(FontRenderStyle* out)
     out->useHinting = useHinting;
     out->hintStyle = hintStyle;
     out->useAntiAlias = useAntiAlias;
-    out->useSubpixel = useSubpixel;
+    out->useSubpixelRendering = useSubpixelRendering != 2 ? useSubpixelRendering : useSubpixel;
+    out->useSubpixelPositioning = useSubpixelPositioning;
 }
 
 void WebFontRenderStyle::setDefaults()
@@ -55,6 +56,8 @@ void WebFontRenderStyle::setDefaults()
     hintStyle = 0;
     useAntiAlias = 2;
     useSubpixel = 2;
+    useSubpixelRendering = 2;
+    useSubpixelPositioning = 2;
 }
 
 } // namespace WebKit
index b9862f5..3399fe1 100644 (file)
@@ -52,7 +52,19 @@ void WebFontRendering::setAntiAlias(bool isAntiAlias)
 // static
 void WebFontRendering::setSubpixelGlyphs(bool isSubpixelGlyphs)
 {
-    FontPlatformData::setSubpixelGlyphs(isSubpixelGlyphs);
+    FontPlatformData::setSubpixelRendering(isSubpixelGlyphs);
+}
+
+// static
+void WebFontRendering::setSubpixelRendering(bool useSubpixelRendering)
+{
+    FontPlatformData::setSubpixelRendering(useSubpixelRendering);
+}
+
+// static
+void WebFontRendering::setSubpixelPositioning(bool useSubpixelPositioning)
+{
+    FontPlatformData::setSubpixelPositioning(useSubpixelPositioning);
 }
 
 // static
index 4e6378a..0924496 100644 (file)
@@ -1,3 +1,18 @@
+2012-06-07  Daniel Erat  <derat@chromium.org>
+
+        [chromium] Add LayoutTestController::setTextSubpixelPositioning() for Linux.
+        https://bugs.webkit.org/show_bug.cgi?id=88263
+
+        Reviewed by Tony Chang.
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::reset):
+        (LayoutTestController::setTextSubpixelPositioning):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        (LayoutTestController):
+        * DumpRenderTree/chromium/fonts.conf:
+
 2012-06-07  Zan Dobersek  <zandobersek@gmail.com>
 
         [Gtk] Assertions in gtk_widget_draw when acquiring pixel output
index 94cee11..b1bf30d 100644 (file)
 #include <wtf/OwnArrayPtr.h>
 #endif
 
+#if OS(LINUX)
+#include "linux/WebFontInfo.h"
+#include "linux/WebFontRendering.h"
+#endif
+
 using namespace WebCore;
 using namespace WebKit;
 using namespace std;
@@ -211,6 +216,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("setPrinting", &LayoutTestController::setPrinting);
     bindMethod("setScrollbarPolicy", &LayoutTestController::setScrollbarPolicy);
     bindMethod("setSelectTrailingWhitespaceEnabled", &LayoutTestController::setSelectTrailingWhitespaceEnabled);
+    bindMethod("setTextSubpixelPositioning", &LayoutTestController::setTextSubpixelPositioning);
     bindMethod("setSmartInsertDeleteEnabled", &LayoutTestController::setSmartInsertDeleteEnabled);
     bindMethod("setStopProvisionalFrameLoads", &LayoutTestController::setStopProvisionalFrameLoads);
     bindMethod("setTabKeyCyclesThroughElements", &LayoutTestController::setTabKeyCyclesThroughElements);
@@ -692,6 +698,10 @@ void LayoutTestController::reset()
     m_taskList.revokeAll();
     m_shouldStayOnPageAfterHandlingBeforeUnload = false;
     m_hasCustomFullScreenBehavior = false;
+#if OS(LINUX)
+    WebFontInfo::setSubpixelPositioning(false);
+    WebFontRendering::setSubpixelPositioning(false);
+#endif
 }
 
 void LayoutTestController::locationChangeDone()
@@ -2172,6 +2182,19 @@ void LayoutTestController::deliverWebIntent(const CppArgumentList& arguments, Cp
     m_shell->webView()->mainFrame()->deliverIntent(intent, 0, m_intentClient.get());
 }
 
+void LayoutTestController::setTextSubpixelPositioning(const CppArgumentList& arguments, CppVariant* result)
+{
+#if OS(LINUX)
+    // Since FontConfig doesn't provide a variable to control subpixel positioning, we'll fall back
+    // to setting it globally for all fonts.
+    if (arguments.size() > 0 && arguments[0].isBool()) {
+        WebFontInfo::setSubpixelPositioning(arguments[0].value.boolValue);
+        WebFontRendering::setSubpixelPositioning(arguments[0].value.boolValue);
+    }
+#endif
+    result->setNull();
+}
+
 void LayoutTestController::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* result)
 {
     if (arguments.size() > 0 && arguments[0].isBool()) {
index 3797865..81cc18f 100644 (file)
@@ -444,6 +444,13 @@ public:
     // Cause the web intent to be delivered to this context.
     void deliverWebIntent(const CppArgumentList&, CppVariant*);
 
+    // Enables or disables subpixel positioning (i.e. fractional X positions for
+    // glyphs) in text rendering on Linux. Since this method changes global
+    // settings, tests that call it must use their own custom font family for
+    // all text that they render. If not, an already-cached style will be used,
+    // resulting in the changed setting being ignored.
+    void setTextSubpixelPositioning(const CppArgumentList&, CppVariant*);
+
 public:
     // The following methods are not exposed to JavaScript.
     void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); }
index b75a932..8e4f8d7 100644 (file)
     </edit>
   </match>
 
+  <match target="pattern">
+    <!-- FontConfig doesn't currently provide a well-defined way to turn on
+         subpixel positioning.  This is just an arbitrary pattern to use after
+         turning subpixel positioning on globally to ensure that we don't have
+         issues with our style getting cached for other tests. -->
+    <test name="family" compare="eq">
+      <string>SubpixelPositioning</string>
+    </test>
+    <edit name="family" mode="assign">
+      <string>Times New Roman</string>
+    </edit>
+  </match>
+
 </fontconfig>