Title: [186205] trunk
Revision
186205
Author
[email protected]
Date
2015-07-01 17:02:15 -0700 (Wed, 01 Jul 2015)

Log Message

[iOS] Support bold and thin italicized system fonts
https://bugs.webkit.org/show_bug.cgi?id=146463
<rdar://problem/20948885>

Reviewed by Darin Adler.

Source/WebCore:

Add the italicized attribute to font descriptors.

Test: fast/text/weighted-italicized-system-font.html

* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::createCTFontWithFamilyNameAndWeight):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::fontWithFamilySpecialCase):
(WebCore::fontWithFamily):
* platform/spi/cocoa/CoreTextSPI.h:

LayoutTests:

* fast/text/weighted-italicized-system-font-expected.html: Added.
* fast/text/weighted-italicized-system-font.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (186204 => 186205)


--- trunk/LayoutTests/ChangeLog	2015-07-02 00:00:12 UTC (rev 186204)
+++ trunk/LayoutTests/ChangeLog	2015-07-02 00:02:15 UTC (rev 186205)
@@ -1,3 +1,14 @@
+2015-07-01  Myles C. Maxfield  <[email protected]>
+
+        [iOS] Support bold and thin italicized system fonts
+        https://bugs.webkit.org/show_bug.cgi?id=146463
+        <rdar://problem/20948885>
+
+        Reviewed by Darin Adler.
+
+        * fast/text/weighted-italicized-system-font-expected.html: Added.
+        * fast/text/weighted-italicized-system-font.html: Added.
+
 2015-07-01  Matthew Mirman  <[email protected]>
 
         Unreviewed, rolling out r185889

Added: trunk/LayoutTests/fast/text/weighted-italicized-system-font-expected.html (0 => 186205)


--- trunk/LayoutTests/fast/text/weighted-italicized-system-font-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/weighted-italicized-system-font-expected.html	2015-07-02 00:02:15 UTC (rev 186205)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that bold &amp; thin italicized system fonts render without synthetic bold.
+<div style="font: 100px -apple-system; font-style: italic;">
+<span style="font-weight: 100;">a</span>
+<span style="font-weight: 700;">a</span>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/weighted-italicized-system-font.html (0 => 186205)


--- trunk/LayoutTests/fast/text/weighted-italicized-system-font.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/weighted-italicized-system-font.html	2015-07-02 00:02:15 UTC (rev 186205)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that bold &amp; thin italicized system fonts render without synthetic bold.
+<div style="font: 100px -apple-system; font-synthesis: none; font-style: italic;">
+<span style="font-weight: 100;">a</span>
+<span style="font-weight: 700;">a</span>
+</div>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac-mavericks/fast/text/weighted-italicized-system-font-expected.html (0 => 186205)


--- trunk/LayoutTests/platform/mac-mavericks/fast/text/weighted-italicized-system-font-expected.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mavericks/fast/text/weighted-italicized-system-font-expected.html	2015-07-02 00:02:15 UTC (rev 186205)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that bold &amp; thin italicized system fonts render without synthetic bold.
+<div style="font: 100px -apple-system;">
+<span style="font-weight: 100;">a</span>
+<span style="font-weight: 700;">a</span>
+</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (186204 => 186205)


--- trunk/Source/WebCore/ChangeLog	2015-07-02 00:00:12 UTC (rev 186204)
+++ trunk/Source/WebCore/ChangeLog	2015-07-02 00:02:15 UTC (rev 186205)
@@ -1,3 +1,22 @@
+2015-07-01  Myles C. Maxfield  <[email protected]>
+
+        [iOS] Support bold and thin italicized system fonts
+        https://bugs.webkit.org/show_bug.cgi?id=146463
+        <rdar://problem/20948885>
+
+        Reviewed by Darin Adler.
+
+        Add the italicized attribute to font descriptors.
+
+        Test: fast/text/weighted-italicized-system-font.html
+
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::createCTFontWithFamilyNameAndWeight):
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::fontWithFamilySpecialCase):
+        (WebCore::fontWithFamily):
+        * platform/spi/cocoa/CoreTextSPI.h:
+
 2015-07-01  Alex Christensen  <[email protected]>
 
         Fix ANGLE Windows build after r186169.

Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (186204 => 186205)


--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-07-02 00:00:12 UTC (rev 186204)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-07-02 00:02:15 UTC (rev 186205)
@@ -615,11 +615,8 @@
         if (weight > 300) {
             // The comment below has been copied from CoreText/UIFoundation. However, in WebKit we synthesize the oblique,
             // so we should investigate the result <rdar://problem/14449340>:
-            // We don't do bold-italic for system fonts. If you ask for it, we'll assume that you're just kidding and that you really want bold. This is a feature.
             if (traits & kCTFontTraitBold)
                 fontType = kCTFontUIFontEmphasizedSystem;
-            else if (traits & kCTFontTraitItalic)
-                fontType = static_cast<CTFontUIFontType>(kCTFontUIFontSystemItalic);
         } else if (weight > 250)
             fontType = static_cast<CTFontUIFontType>(kCTFontUIFontSystemLight);
         else if (weight > 150)
@@ -627,6 +624,8 @@
         else
             fontType = static_cast<CTFontUIFontType>(kCTFontUIFontSystemUltraLight);
         RetainPtr<CTFontDescriptorRef> fontDescriptor = adoptCF(CTFontDescriptorCreateForUIType(fontType, size, nullptr));
+        if (traits & kCTFontTraitItalic)
+            fontDescriptor = adoptCF(CTFontDescriptorCreateCopyWithSymbolicTraits(fontDescriptor.get(), kCTFontItalicTrait, kCTFontItalicTrait));
         return CTFontCreateWithFontDescriptor(fontDescriptor.get(), size, nullptr);
     }
 

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (186204 => 186205)


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-07-02 00:00:12 UTC (rev 186204)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-07-02 00:02:15 UTC (rev 186205)
@@ -228,16 +228,19 @@
 }
 #endif
 
-static Optional<NSFont*> fontWithFamilySpecialCase(const AtomicString& family, FontWeight weight, float size)
+static Optional<NSFont*> fontWithFamilySpecialCase(const AtomicString& family, FontWeight weight, NSFontTraitMask desiredTraits, float size)
 {
     if (equalIgnoringASCIICase(family, "-webkit-system-font")
         || equalIgnoringASCIICase(family, "-apple-system")
         || equalIgnoringASCIICase(family, "-apple-system-font")) {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
-        return [NSFont systemFontOfSize:size weight:toNSFontWeight(weight)];
+        NSFont *result = [NSFont systemFontOfSize:size weight:toNSFontWeight(weight)];
 #else
-        return (weight >= FontWeight600) ? [NSFont boldSystemFontOfSize:size] : [NSFont systemFontOfSize:size];
+        NSFont *result = (weight >= FontWeight600) ? [NSFont boldSystemFontOfSize:size] : [NSFont systemFontOfSize:size];
 #endif
+        if (desiredTraits & NSFontItalicTrait)
+            result = [[NSFontManager sharedFontManager] convertFont:result toHaveTrait:desiredTraits];
+        return result;
     }
 
     if (equalIgnoringASCIICase(family, "-apple-system-monospaced-numbers")) {
@@ -263,7 +266,7 @@
 // we then do a search based on the family names of the installed fonts.
 static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, float size)
 {
-    if (const auto& specialCase = fontWithFamilySpecialCase(family, weight, size))
+    if (const auto& specialCase = fontWithFamilySpecialCase(family, weight, desiredTraits, size))
         return specialCase.value();
 
     NSFontManager *fontManager = [NSFontManager sharedFontManager];

Modified: trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h (186204 => 186205)


--- trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h	2015-07-02 00:00:12 UTC (rev 186204)
+++ trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h	2015-07-02 00:02:15 UTC (rev 186205)
@@ -75,6 +75,7 @@
 
 CTFontDescriptorRef CTFontDescriptorCreateForUIType(CTFontUIFontType, CGFloat size, CFStringRef language);
 CTFontDescriptorRef CTFontDescriptorCreateWithTextStyle(CFStringRef style, CFStringRef size, CFStringRef language);
+CTFontDescriptorRef CTFontDescriptorCreateCopyWithSymbolicTraits(CTFontDescriptorRef original, CTFontSymbolicTraits symTraitValue, CTFontSymbolicTraits symTraitMask);
 
 #if PLATFORM(COCOA)
 #if !USE(APPLE_INTERNAL_SDK)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to