Title: [245191] trunk
- Revision
- 245191
- Author
- [email protected]
- Date
- 2019-05-10 13:30:05 -0700 (Fri, 10 May 2019)
Log Message
[iOS] baidu.com: Synthetic bold renders too far apart, appears doubled.
https://bugs.webkit.org/show_bug.cgi?id=197781
<rdar://problem/48027412>
Reviewed by Simon Fraser.
Source/WebCore:
Synthetic bold is essentially two regular glyphs painted with an offset. While on macOS this offset is always 1px (CSS), on iOS larger font produces higher offset value. At paint time, this offset value (in CSS px unit) get converted
to a device pixel value taking context scale into account. This conversion ensures that the gap between the 2 regular glyphs won't get wider (in device pixels) as the user pinch zooms in.
This works as long as the scale on the context is >= 1. This patch ensures that a scaled down context won't blow up this gap.
Test: fast/text/large-synthetic-bold-with-scale-transform.html
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::FontCascade::drawGlyphs):
LayoutTests:
* fast/text/large-synthetic-bold-with-scale-transform-expected.html: Added.
* fast/text/large-synthetic-bold-with-scale-transform.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (245190 => 245191)
--- trunk/LayoutTests/ChangeLog 2019-05-10 20:10:59 UTC (rev 245190)
+++ trunk/LayoutTests/ChangeLog 2019-05-10 20:30:05 UTC (rev 245191)
@@ -1,3 +1,14 @@
+2019-05-10 Zalan Bujtas <[email protected]>
+
+ [iOS] baidu.com: Synthetic bold renders too far apart, appears doubled.
+ https://bugs.webkit.org/show_bug.cgi?id=197781
+ <rdar://problem/48027412>
+
+ Reviewed by Simon Fraser.
+
+ * fast/text/large-synthetic-bold-with-scale-transform-expected.html: Added.
+ * fast/text/large-synthetic-bold-with-scale-transform.html: Added.
+
2019-05-10 Simon Fraser <[email protected]>
ASSERT(isSelfPaintingLayer() || hasSelfPaintingLayerDescendant()) on nytimes.com after r245170
Added: trunk/LayoutTests/fast/text/large-synthetic-bold-with-scale-transform-expected.html ( => )
Added: trunk/LayoutTests/fast/text/large-synthetic-bold-with-scale-transform.html
===================================================================
--- trunk/LayoutTests/fast/text/large-synthetic-bold-with-scale-transform.html (rev 0)
+++ trunk/LayoutTests/fast/text/large-synthetic-bold-with-scale-transform.html 2019-05-10 20:30:05 UTC (rev 245191)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we don't end up painting large gaps for synthetic bold when tall text gets scaled down.</title>
+<style>
+ body {
+ font-family: 'Hiragino Maru Gothic ProN';
+ font-weight: bold;
+ font-size: 900px;
+ margin: 0px;
+ }
+
+ div {
+ transform: scale(0.01);
+ height: 20px;
+ width: 20px;
+ }
+
+ .cover {
+ transform: none;
+ background-color: white;
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ height: 150px;
+ width: 20px;
+ }
+</style>
+</head>
+<body>
+<div>F</div>
+<div>o</div>
+<div>o</div>
+<div>B</div>
+<div>a</div>
+<div>r</div>
+<div class=cover></div>
+</div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (245190 => 245191)
--- trunk/Source/WebCore/ChangeLog 2019-05-10 20:10:59 UTC (rev 245190)
+++ trunk/Source/WebCore/ChangeLog 2019-05-10 20:30:05 UTC (rev 245191)
@@ -1,3 +1,20 @@
+2019-05-10 Zalan Bujtas <[email protected]>
+
+ [iOS] baidu.com: Synthetic bold renders too far apart, appears doubled.
+ https://bugs.webkit.org/show_bug.cgi?id=197781
+ <rdar://problem/48027412>
+
+ Reviewed by Simon Fraser.
+
+ Synthetic bold is essentially two regular glyphs painted with an offset. While on macOS this offset is always 1px (CSS), on iOS larger font produces higher offset value. At paint time, this offset value (in CSS px unit) get converted
+ to a device pixel value taking context scale into account. This conversion ensures that the gap between the 2 regular glyphs won't get wider (in device pixels) as the user pinch zooms in.
+ This works as long as the scale on the context is >= 1. This patch ensures that a scaled down context won't blow up this gap.
+
+ Test: fast/text/large-synthetic-bold-with-scale-transform.html
+
+ * platform/graphics/cocoa/FontCascadeCocoa.mm:
+ (WebCore::FontCascade::drawGlyphs):
+
2019-05-10 Brent Fulgham <[email protected]>
Gracefully handle inaccessible font face data
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (245190 => 245191)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm 2019-05-10 20:10:59 UTC (rev 245190)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm 2019-05-10 20:30:05 UTC (rev 245191)
@@ -276,8 +276,10 @@
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;
+ if (horizontalUnitLengthInDevicePixels) {
+ // Make sure that a scaled down context won't blow up the gap between the glyphs.
+ syntheticBoldOffset = std::min(syntheticBoldOffset, syntheticBoldOffset / horizontalUnitLengthInDevicePixels);
+ }
};
bool hasSimpleShadow = context.textDrawingMode() == TextModeFill && shadowColor.isValid() && !shadowBlur && !platformData.isColorBitmapFont() && (!context.shadowsIgnoreTransforms() || contextCTM.isIdentityOrTranslationOrFlipped()) && !context.isInTransparencyLayer();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes