From 83ff1e35e7964d8503bc3da65068856f9991c2a6 Mon Sep 17 00:00:00 2001 From: "mitz@apple.com" Date: Wed, 8 Feb 2012 00:59:11 +0000 Subject: [PATCH] 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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107012 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 10 ++++++++++ .../text/synthetic-bold-transformed-expected.html | 4 ++++ LayoutTests/fast/text/synthetic-bold-transformed.html | 1 + Source/WebCore/ChangeLog | 13 +++++++++++++ Source/WebCore/platform/graphics/mac/FontMac.mm | 19 ++++++++++++++----- 5 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 LayoutTests/fast/text/synthetic-bold-transformed-expected.html create mode 100644 LayoutTests/fast/text/synthetic-bold-transformed.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index a771e89..21c45ff 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2012-02-07 Dan Bernstein + + 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 Add JSC support for delivering mutations when the outermost script context exits diff --git a/LayoutTests/fast/text/synthetic-bold-transformed-expected.html b/LayoutTests/fast/text/synthetic-bold-transformed-expected.html new file mode 100644 index 0000000..8d3be39 --- /dev/null +++ b/LayoutTests/fast/text/synthetic-bold-transformed-expected.html @@ -0,0 +1,4 @@ +
+
|
+
|
+
diff --git a/LayoutTests/fast/text/synthetic-bold-transformed.html b/LayoutTests/fast/text/synthetic-bold-transformed.html new file mode 100644 index 0000000..426f6ce --- /dev/null +++ b/LayoutTests/fast/text/synthetic-bold-transformed.html @@ -0,0 +1 @@ +
|
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index ae1c8b9..5789760 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,16 @@ +2012-02-07 Dan Bernstein + + 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 Update LayoutUnit usage in ColumnInfo and RenderFrameSet diff --git a/Source/WebCore/platform/graphics/mac/FontMac.mm b/Source/WebCore/platform/graphics/mac/FontMac.mm index 8e23339..4afb5fb 100644 --- a/Source/WebCore/platform/graphics/mac/FontMac.mm +++ b/Source/WebCore/platform/graphics/mac/FontMac.mm @@ -222,7 +222,16 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons 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 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons // 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); -- 2.7.4