Title: [218616] trunk
Revision
218616
Author
mmaxfi...@apple.com
Date
2017-06-20 16:52:22 -0700 (Tue, 20 Jun 2017)

Log Message

[Cocoa] The system Japanese font cannot be italicized
https://bugs.webkit.org/show_bug.cgi?id=173300
<rdar://problem/31805407>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Items in the system font cascade list may lie about whether or not they support italics.
In order to get the truth, we need to use the physical font underlying the font in question,
because this one won't lie. Then, we can interrogate this physical font about its traits
in order to synthesize italics correctly.

Test: fast/text/system-font-japanese-synthetic-italic.html

* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::lookupFallbackFont):
* platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp:
(WebCore::FontFamilySpecificationCoreText::fontRanges):

LayoutTests:

* fast/text/system-font-japanese-synthetic-italic-expected-mismatch.html: Added.
* fast/text/system-font-japanese-synthetic-italic.html: Added.
* platform/mac/TestExpectations: This codepath doesn't work in El Capitan.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (218615 => 218616)


--- trunk/LayoutTests/ChangeLog	2017-06-20 23:42:18 UTC (rev 218615)
+++ trunk/LayoutTests/ChangeLog	2017-06-20 23:52:22 UTC (rev 218616)
@@ -1,3 +1,15 @@
+2017-06-20  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] The system Japanese font cannot be italicized
+        https://bugs.webkit.org/show_bug.cgi?id=173300
+        <rdar://problem/31805407>
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/text/system-font-japanese-synthetic-italic-expected-mismatch.html: Added.
+        * fast/text/system-font-japanese-synthetic-italic.html: Added.
+        * platform/mac/TestExpectations: This codepath doesn't work in El Capitan.
+
 2017-06-20  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r218524.

Added: trunk/LayoutTests/fast/text/system-font-japanese-synthetic-italic-expected-mismatch.html (0 => 218616)


--- trunk/LayoutTests/fast/text/system-font-japanese-synthetic-italic-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/system-font-japanese-synthetic-italic-expected-mismatch.html	2017-06-20 23:52:22 UTC (rev 218616)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+This test makes sure that the Japanese system font can be italicized. The test passes if the character below is oblique (either because the font supports it or because WebKit synthesizes the oblique).
+<div style="font: 100px 'system-ui';">の</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/system-font-japanese-synthetic-italic.html (0 => 218616)


--- trunk/LayoutTests/fast/text/system-font-japanese-synthetic-italic.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/system-font-japanese-synthetic-italic.html	2017-06-20 23:52:22 UTC (rev 218616)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+</head>
+<body>
+This test makes sure that the Japanese system font can be italicized. The test passes if the character below is oblique (either because the font supports it or because WebKit synthesizes the oblique).
+<div style="font: 100px 'system-ui'; font-style: italic;">の</div>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac/TestExpectations (218615 => 218616)


--- trunk/LayoutTests/platform/mac/TestExpectations	2017-06-20 23:42:18 UTC (rev 218615)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2017-06-20 23:52:22 UTC (rev 218616)
@@ -1605,3 +1605,4 @@
 
 webkit.org/b/173487 imported/w3c/web-platform-tests/IndexedDB/large-nested-cloning.html [ Pass Failure ]
 
+webkit.org/b/313156 [ ElCapitan ] fast/text/system-font-japanese-synthetic-italic.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (218615 => 218616)


--- trunk/Source/WebCore/ChangeLog	2017-06-20 23:42:18 UTC (rev 218615)
+++ trunk/Source/WebCore/ChangeLog	2017-06-20 23:52:22 UTC (rev 218616)
@@ -1,3 +1,23 @@
+2017-06-20  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] The system Japanese font cannot be italicized
+        https://bugs.webkit.org/show_bug.cgi?id=173300
+        <rdar://problem/31805407>
+
+        Reviewed by Ryosuke Niwa.
+
+        Items in the system font cascade list may lie about whether or not they support italics.
+        In order to get the truth, we need to use the physical font underlying the font in question,
+        because this one won't lie. Then, we can interrogate this physical font about its traits
+        in order to synthesize italics correctly.
+
+        Test: fast/text/system-font-japanese-synthetic-italic.html
+
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::lookupFallbackFont):
+        * platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp:
+        (WebCore::FontFamilySpecificationCoreText::fontRanges):
+
 2017-06-20  Chris Dumez  <cdu...@apple.com>
 
         Use WTF::Function instead of std::function in more places in WebCore/

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (218615 => 218616)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-06-20 23:42:18 UTC (rev 218615)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-06-20 23:52:22 UTC (rev 218616)
@@ -1292,7 +1292,12 @@
 #endif
 
     CFIndex coveredLength = 0;
-    auto result = adoptCF(CTFontCreateForCharactersWithLanguage(font, characters, length, localeString.get(), &coveredLength));
+    RetainPtr<CTFontRef> result;
+#if !USE_PLATFORM_SYSTEM_FALLBACK_LIST && ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000))
+    result = adoptCF(CTFontCreatePhysicalFontForCharactersWithLanguage(font, characters, length, localeString.get(), &coveredLength));
+#else
+    result = adoptCF(CTFontCreateForCharactersWithLanguage(font, characters, length, localeString.get(), &coveredLength));
+#endif
 
 #if PLATFORM(IOS)
     // Callers of this function won't include multiple code points. "Length" is to know how many code units

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp (218615 => 218616)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp	2017-06-20 23:42:18 UTC (rev 218615)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp	2017-06-20 23:52:22 UTC (rev 218616)
@@ -28,8 +28,14 @@
 
 #include "FontCache.h"
 #include "FontSelector.h"
+#include "SoftLinking.h"
 #include <CoreText/CoreText.h>
 
+#if USE_PLATFORM_SYSTEM_FALLBACK_LIST
+SOFT_LINK_FRAMEWORK(CoreText);
+SOFT_LINK_MAY_FAIL(CoreText, CTFontCopyPhysicalFont, CTFontRef, (CTFontRef font), (font));
+#endif
+
 namespace WebCore {
 
 FontFamilySpecificationCoreText::FontFamilySpecificationCoreText(CTFontDescriptorRef fontDescriptor)
@@ -47,10 +53,18 @@
 
     auto font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
 
+    auto fontForSynthesisComputation = font;
+#if USE_PLATFORM_SYSTEM_FALLBACK_LIST
+    if (canLoadCTFontCopyPhysicalFont()) {
+        if (auto physicalFont = adoptCF(CTFontCopyPhysicalFont(font.get())))
+            fontForSynthesisComputation = physicalFont;
+    }
+#endif
+
     font = preparePlatformFont(font.get(), fontDescription, nullptr, nullptr, { }, fontDescription.computedSize());
 
     bool syntheticBold, syntheticOblique;
-    std::tie(syntheticBold, syntheticOblique) = computeNecessarySynthesis(font.get(), fontDescription).boldObliquePair();
+    std::tie(syntheticBold, syntheticOblique) = computeNecessarySynthesis(fontForSynthesisComputation.get(), fontDescription).boldObliquePair();
 
     FontPlatformData fontPlatformData(font.get(), size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.textRenderingMode());
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to