text-decoration-skip: ink skips randomly when using SVG fonts
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Feb 2014 00:30:15 +0000 (00:30 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Feb 2014 00:30:15 +0000 (00:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128709

Reviewed by Simon Fraser.

Source/WebCore:

This patch simply disables skipping underlines being used with SVG fonts.
It's a stopgap until we can support skipping properly with SVG fonts.

Test: svg/custom/svg-fonts-skip-ink.html

* platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::FontPlatformData::ctFont):
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::dashesForIntersectionsWithRect):

LayoutTests:

This text checks that some text without descenders in an SVG font renders the same with and
without text-decoration-skip: ink.

* svg/custom/svg-fonts-skip-ink-expected.html: Added.
* svg/custom/svg-fonts-skip-ink.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/svg-fonts-skip-ink-expected.html [new file with mode: 0644]
LayoutTests/svg/custom/svg-fonts-skip-ink.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
Source/WebCore/platform/graphics/mac/FontMac.mm

index 5d065db06a1389c9a3b126be85d4e928ca0e66d0..789c3c07e4ccd428971bf1baedc17eae0e3e2a59 100644 (file)
@@ -1,3 +1,16 @@
+2014-02-13  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        text-decoration-skip: ink skips randomly when using SVG fonts
+        https://bugs.webkit.org/show_bug.cgi?id=128709
+
+        Reviewed by Simon Fraser.
+
+        This text checks that some text without descenders in an SVG font renders the same with and
+        without text-decoration-skip: ink.
+
+        * svg/custom/svg-fonts-skip-ink-expected.html: Added.
+        * svg/custom/svg-fonts-skip-ink.html: Added.
+
 2014-02-13  Brent Fulgham  <bfulgham@apple.com>
 
         Create some latched scrolling tests.
diff --git a/LayoutTests/svg/custom/svg-fonts-skip-ink-expected.html b/LayoutTests/svg/custom/svg-fonts-skip-ink-expected.html
new file mode 100644 (file)
index 0000000..950d430
--- /dev/null
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: 'SVGraffiti';
+    src: url("resources/graffiti.svg#SVGraffiti") format(svg)
+}
+body {
+    font:100px 'SVGraffiti';
+    -webkit-text-decoration-skip: none;
+    text-decoration: underline;
+}
+</style>
+</head>
+<body>
+NSNorth Podcast
+</body>
+</html>
diff --git a/LayoutTests/svg/custom/svg-fonts-skip-ink.html b/LayoutTests/svg/custom/svg-fonts-skip-ink.html
new file mode 100644 (file)
index 0000000..0fd8595
--- /dev/null
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: 'SVGraffiti';
+    src: url("resources/graffiti.svg#SVGraffiti") format(svg)
+}
+body {
+    font:100px 'SVGraffiti';
+    -webkit-text-decoration-skip: ink;
+    text-decoration: underline;
+}
+</style>
+</head>
+<body>
+NSNorth Podcast
+</body>
+</html>
index 279033007e767e0fd0908bda3784d33c5c5b7a72..22e9ce3113cb40aba045bab9d55795dad863a8e7 100644 (file)
@@ -1,3 +1,20 @@
+2014-02-13  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        text-decoration-skip: ink skips randomly when using SVG fonts
+        https://bugs.webkit.org/show_bug.cgi?id=128709
+
+        Reviewed by Simon Fraser.
+
+        This patch simply disables skipping underlines being used with SVG fonts.
+        It's a stopgap until we can support skipping properly with SVG fonts.
+
+        Test: svg/custom/svg-fonts-skip-ink.html
+
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::FontPlatformData::ctFont):
+        * platform/graphics/mac/FontMac.mm:
+        (WebCore::Font::dashesForIntersectionsWithRect):
+
 2014-02-13  Daniel Bates  <dabates@apple.com>
 
         Fix the ARM build when HAVE_ARM_NEON_INTRINSICS is enabled
index e9a92e7086d684e7cf609fa2fed203d952d0ae37..19fbd17d1f1a68d9d21210969d7982ba0e64bf3b 100644 (file)
@@ -319,8 +319,10 @@ CTFontRef FontPlatformData::ctFont() const
         else
             fontDescriptor = cascadeToLastResortFontDescriptor();
         m_CTFont = adoptCF(CTFontCreateCopyWithAttributes(m_CTFont.get(), m_size, 0, fontDescriptor));
-    } else
+    } else {
+        ASSERT(m_cgFont.get());
         m_CTFont = adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), m_size, 0, cascadeToLastResortFontDescriptor()));
+    }
 #else
     // Apple Color Emoji size is adjusted (and then re-adjusted by Core Text) and capped.
     CGFloat size = !m_isEmoji ? m_size : m_size <= 15 ? 4 * (m_size + 2) / static_cast<CGFloat>(5) : 16;
index eae3b074c384a97bf304f4265fc7944bfe93a490..362d70851184556091744e587fc0d48faeb3d529 100644 (file)
@@ -438,6 +438,9 @@ static void findPathIntersections(void* stateAsVoidPointer, const CGPathElement*
 
 DashArray Font::dashesForIntersectionsWithRect(const TextRun& run, const FloatPoint& textOrigin, const FloatRect& lineExtents) const
 {
+    if (loadingCustomFonts())
+        return DashArray();
+
     float deltaX;
     GlyphBuffer glyphBuffer;
     if (codePath(run) != Complex)
@@ -449,7 +452,10 @@ DashArray Font::dashesForIntersectionsWithRect(const TextRun& run, const FloatPo
     DashArray result;
     for (int i = 0; i < glyphBuffer.size(); ++i) {
         GlyphIterationState info = GlyphIterationState(CGPointMake(0, 0), CGPointMake(0, 0), lineExtents.y(), lineExtents.y() + lineExtents.height(), lineExtents.x() + lineExtents.width(), lineExtents.x());
-        RetainPtr<CGPathRef> path = adoptCF(CTFontCreatePathForGlyph(glyphBuffer.fontDataAt(i)->platformData().ctFont(), glyphBuffer.glyphAt(i), &translation));
+        const SimpleFontData* fontData = glyphBuffer.fontDataAt(i);
+        if (fontData->isSVGFont())
+            continue;
+        RetainPtr<CGPathRef> path = adoptCF(CTFontCreatePathForGlyph(fontData->platformData().ctFont(), glyphBuffer.glyphAt(i), &translation));
         CGPathApply(path.get(), &info, &findPathIntersections);
         if (info.minX < info.maxX) {
             result.append(info.minX - lineExtents.x());