Title: [107012] trunk
Revision
107012
Author
m...@apple.com
Date
2012-02-07 16:59:11 -0800 (Tue, 07 Feb 2012)

Log Message

<rdar://problem/10475450> Synthetic bold is illegible under some scaling transforms
https://bugs.webkit.org/show_bug.cgi?id=78044

Reviewed by Beth Dakin.

Source/WebCore: 

Tests: fast/text/synthetic-bold-transformed-expected.html
       fast/text/synthetic-bold-transformed.html

* platform/graphics/mac/FontMac.mm:
(WebCore::Font::drawGlyphs): Changed to interpret syntheticBoldOffset as a length in device pixels.

LayoutTests: 

* fast/text/synthetic-bold-transformed-expected.html: Added.
* fast/text/synthetic-bold-transformed.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (107011 => 107012)


--- trunk/LayoutTests/ChangeLog	2012-02-08 00:58:59 UTC (rev 107011)
+++ trunk/LayoutTests/ChangeLog	2012-02-08 00:59:11 UTC (rev 107012)
@@ -1,3 +1,13 @@
+2012-02-07  Dan Bernstein  <m...@apple.com>
+
+        <rdar://problem/10475450> Synthetic bold is illegible under some scaling transforms
+        https://bugs.webkit.org/show_bug.cgi?id=78044
+
+        Reviewed by Beth Dakin.
+
+        * fast/text/synthetic-bold-transformed-expected.html: Added.
+        * fast/text/synthetic-bold-transformed.html: Added.
+
 2012-02-07  Adam Klein  <ad...@chromium.org>
 
         Add JSC support for delivering mutations when the outermost script context exits

Added: trunk/LayoutTests/fast/text/synthetic-bold-transformed-expected.html (0 => 107012)


--- trunk/LayoutTests/fast/text/synthetic-bold-transformed-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/synthetic-bold-transformed-expected.html	2012-02-08 00:59:11 UTC (rev 107012)
@@ -0,0 +1,4 @@
+<div style="position: relative;">
+    <div style="-webkit-transform-origin: 0 0; -webkit-transform: scale(8); font-family: STSong;">|</div>
+    <div style="position: absolute; top: 0; -webkit-transform-origin: 0 0; -webkit-transform: translatex(1px) scale(8); font-family: STSong;">|</div>
+</div>

Added: trunk/LayoutTests/fast/text/synthetic-bold-transformed.html (0 => 107012)


--- trunk/LayoutTests/fast/text/synthetic-bold-transformed.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/synthetic-bold-transformed.html	2012-02-08 00:59:11 UTC (rev 107012)
@@ -0,0 +1 @@
+<div style="-webkit-transform-origin: 0 0; -webkit-transform: scale(8); font-family: STSong; font-weight: bold;">|</div>

Modified: trunk/Source/WebCore/ChangeLog (107011 => 107012)


--- trunk/Source/WebCore/ChangeLog	2012-02-08 00:58:59 UTC (rev 107011)
+++ trunk/Source/WebCore/ChangeLog	2012-02-08 00:59:11 UTC (rev 107012)
@@ -1,3 +1,16 @@
+2012-02-07  Dan Bernstein  <m...@apple.com>
+
+        <rdar://problem/10475450> Synthetic bold is illegible under some scaling transforms
+        https://bugs.webkit.org/show_bug.cgi?id=78044
+
+        Reviewed by Beth Dakin.
+
+        Tests: fast/text/synthetic-bold-transformed-expected.html
+               fast/text/synthetic-bold-transformed.html
+
+        * platform/graphics/mac/FontMac.mm:
+        (WebCore::Font::drawGlyphs): Changed to interpret syntheticBoldOffset as a length in device pixels.
+
 2012-02-07  Levi Weintraub  <le...@chromium.org>
 
         Update LayoutUnit usage in ColumnInfo and RenderFrameSet

Modified: trunk/Source/WebCore/platform/graphics/mac/FontMac.mm (107011 => 107012)


--- trunk/Source/WebCore/platform/graphics/mac/FontMac.mm	2012-02-08 00:58:59 UTC (rev 107011)
+++ trunk/Source/WebCore/platform/graphics/mac/FontMac.mm	2012-02-08 00:59:11 UTC (rev 107012)
@@ -222,7 +222,16 @@
     ColorSpace fillColorSpace = context->fillColorSpace();
     context->getShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
 
-    bool hasSimpleShadow = context->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && !platformData.isColorBitmapFont() && (!context->shadowsIgnoreTransforms() || context->getCTM().isIdentityOrTranslationOrFlipped()) && !context->isInTransparencyLayer();
+    AffineTransform contextCTM = context->getCTM();
+    float syntheticBoldOffset = font->syntheticBoldOffset();
+    if (syntheticBoldOffset && !contextCTM.isIdentityOrTranslationOrFlipped()) {
+        FloatSize horizontalUnitSizeInDevicePixels = contextCTM.mapSize(FloatSize(1, 0));
+        float horizontalUnitLengthInDevicePixels = sqrtf(horizontalUnitSizeInDevicePixels.width() * horizontalUnitSizeInDevicePixels.width() + horizontalUnitSizeInDevicePixels.height() * horizontalUnitSizeInDevicePixels.height());
+        if (horizontalUnitLengthInDevicePixels)
+            syntheticBoldOffset /= horizontalUnitLengthInDevicePixels;
+    };
+
+    bool hasSimpleShadow = context->textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && !platformData.isColorBitmapFont() && (!context->shadowsIgnoreTransforms() || contextCTM.isIdentityOrTranslationOrFlipped()) && !context->isInTransparencyLayer();
     if (hasSimpleShadow) {
         // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.
         context->clearShadow();
@@ -233,14 +242,14 @@
         // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative.
         float shadowTextY = point.y() + shadowOffset.height() * (context->shadowsIgnoreTransforms() ? -1 : 1);
         showGlyphsWithAdvances(FloatPoint(shadowTextX, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
-        if (font->syntheticBoldOffset())
-            showGlyphsWithAdvances(FloatPoint(shadowTextX + font->syntheticBoldOffset(), shadowTextY), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
+        if (syntheticBoldOffset)
+            showGlyphsWithAdvances(FloatPoint(shadowTextX + syntheticBoldOffset, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
         context->setFillColor(fillColor, fillColorSpace);
     }
 
     showGlyphsWithAdvances(point, font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
-    if (font->syntheticBoldOffset())
-        showGlyphsWithAdvances(FloatPoint(point.x() + font->syntheticBoldOffset(), point.y()), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
+    if (syntheticBoldOffset)
+        showGlyphsWithAdvances(FloatPoint(point.x() + syntheticBoldOffset, point.y()), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
 
     if (hasSimpleShadow)
         context->setShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to