Title: [183895] trunk
Revision
183895
Author
jon...@apple.com
Date
2015-05-06 15:55:09 -0700 (Wed, 06 May 2015)

Log Message

Expose more font weights for -apple-system
https://bugs.webkit.org/show_bug.cgi?id=144707

Reviewed by Dean Jackson.

Source/WebCore:

Update to platform/mac/fast/text/systemFont.html

* platform/graphics/mac/FontCacheMac.mm:
(WebCore::toNSFontWeight): New static method to map font weights to NSFontWeight constants available on
Yosemite and later.
(WebCore::fontWithFamily): Request the system font with a mapped weight on Yosemite and later.
* platform/spi/mac/NSFontSPI.h: Add [NSFont systemFontWithSize:weight:], and the proper NSFontWeight
constants.

LayoutTests:

* platform/mac/fast/text/systemFont.html: Update test to include font weights for -apple-system.
* platform/mac/fast/text/systemFont-expected.txt: Update expectations.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (183894 => 183895)


--- trunk/LayoutTests/ChangeLog	2015-05-06 22:46:01 UTC (rev 183894)
+++ trunk/LayoutTests/ChangeLog	2015-05-06 22:55:09 UTC (rev 183895)
@@ -1,3 +1,13 @@
+2015-05-06  Jon Lee  <jon...@apple.com>
+
+        Expose more font weights for -apple-system
+        https://bugs.webkit.org/show_bug.cgi?id=144707
+
+        Reviewed by Dean Jackson.
+
+        * platform/mac/fast/text/systemFont.html: Update test to include font weights for -apple-system.
+        * platform/mac/fast/text/systemFont-expected.txt: Update expectations.
+
 2015-05-06  Dean Jackson  <d...@apple.com>
 
         Handle backdrop views that have to tile

Modified: trunk/LayoutTests/platform/mac/fast/text/systemFont-expected.txt (183894 => 183895)


--- trunk/LayoutTests/platform/mac/fast/text/systemFont-expected.txt	2015-05-06 22:46:01 UTC (rev 183894)
+++ trunk/LayoutTests/platform/mac/fast/text/systemFont-expected.txt	2015-05-06 22:55:09 UTC (rev 183895)
@@ -1,8 +1,8 @@
-layer at (0,0) size 785x2036
+layer at (0,0) size 785x2198
   RenderView at (0,0) size 785x600
-layer at (0,0) size 785x2036
-  RenderBlock {HTML} at (0,0) size 785x2036
-    RenderBody {BODY} at (8,8) size 769x2020
+layer at (0,0) size 785x2198
+  RenderBlock {HTML} at (0,0) size 785x2198
+    RenderBody {BODY} at (8,8) size 769x2182
       RenderBlock {DIV} at (0,0) size 769x897
         RenderBlock {DIV} at (0,0) size 769x28
           RenderText {#text} at (0,0) size 438x28
@@ -78,7 +78,35 @@
           RenderText {#text} at (0,0) size 756x170
             text run at (0,0) width 756: "This is a test for -apple-"
             text run at (0,85) width 373: "system font"
-      RenderBlock {DIV} at (0,1738) size 769x282
+      RenderBlock {DIV} at (0,1738) size 769x162
+        RenderBlock {DIV} at (0,0) size 769x18
+          RenderText {#text} at (0,0) size 302x18
+            text run at (0,0) width 302: "This is a font weight test for -apple-system font"
+        RenderBlock {DIV} at (0,18) size 769x18
+          RenderText {#text} at (0,0) size 316x18
+            text run at (0,0) width 316: "This is a font weight test for -apple-system font"
+        RenderBlock {DIV} at (0,36) size 769x18
+          RenderText {#text} at (0,0) size 335x18
+            text run at (0,0) width 335: "This is a font weight test for -apple-system font"
+        RenderBlock {DIV} at (0,54) size 769x18
+          RenderText {#text} at (0,0) size 350x18
+            text run at (0,0) width 350: "This is a font weight test for -apple-system font"
+        RenderBlock {DIV} at (0,72) size 769x18
+          RenderText {#text} at (0,0) size 362x18
+            text run at (0,0) width 362: "This is a font weight test for -apple-system font"
+        RenderBlock {DIV} at (0,90) size 769x18
+          RenderText {#text} at (0,0) size 374x18
+            text run at (0,0) width 374: "This is a font weight test for -apple-system font"
+        RenderBlock {DIV} at (0,108) size 769x18
+          RenderText {#text} at (0,0) size 374x18
+            text run at (0,0) width 374: "This is a font weight test for -apple-system font"
+        RenderBlock {DIV} at (0,126) size 769x18
+          RenderText {#text} at (0,0) size 396x18
+            text run at (0,0) width 396: "This is a font weight test for -apple-system font"
+        RenderBlock {DIV} at (0,144) size 769x18
+          RenderText {#text} at (0,0) size 396x18
+            text run at (0,0) width 396: "This is a font weight test for -apple-system font"
+      RenderBlock {DIV} at (0,1900) size 769x282
         RenderBlock {DIV} at (0,0) size 769x56
           RenderText {#text} at (0,0) size 644x56
             text run at (0,0) width 644: "This is a test for -apple-system-monospaced-numbers font -"

Modified: trunk/LayoutTests/platform/mac/fast/text/systemFont.html (183894 => 183895)


--- trunk/LayoutTests/platform/mac/fast/text/systemFont.html	2015-05-06 22:46:01 UTC (rev 183894)
+++ trunk/LayoutTests/platform/mac/fast/text/systemFont.html	2015-05-06 22:55:09 UTC (rev 183895)
@@ -24,6 +24,17 @@
         <div style="font-family: -apple-system; font-size: 72px">This is a test for -apple-system font</div>
     </div>
     <div>
+        <div style="font-family: -apple-system; font-weight: 100">This is a font weight test for -apple-system font</div>
+        <div style="font-family: -apple-system; font-weight: 200">This is a font weight test for -apple-system font</div>
+        <div style="font-family: -apple-system; font-weight: 300">This is a font weight test for -apple-system font</div>
+        <div style="font-family: -apple-system; font-weight: 400">This is a font weight test for -apple-system font</div>
+        <div style="font-family: -apple-system; font-weight: 500">This is a font weight test for -apple-system font</div>
+        <div style="font-family: -apple-system; font-weight: 600">This is a font weight test for -apple-system font</div>
+        <div style="font-family: -apple-system; font-weight: 700">This is a font weight test for -apple-system font</div>
+        <div style="font-family: -apple-system; font-weight: 800">This is a font weight test for -apple-system font</div>
+        <div style="font-family: -apple-system; font-weight: 900">This is a font weight test for -apple-system font</div>
+    </div>
+    <div>
         <div style="font-family: -apple-system-monospaced-numbers; font-size: 24px">This is a test for -apple-system-monospaced-numbers font - 00:11:22:33</div>
         <div style="font: 30.0px '-apple-system-monospaced-numbers'">This is a test for -apple-system-monospaced-numbers font - 00:11:22:33</div>
         <div style="font-family: -apple-system-monospaced-numbers; font-size: 30px">This is a test for -apple-system-monospaced-numbers font - 00:11:22:33</div>

Modified: trunk/Source/WebCore/ChangeLog (183894 => 183895)


--- trunk/Source/WebCore/ChangeLog	2015-05-06 22:46:01 UTC (rev 183894)
+++ trunk/Source/WebCore/ChangeLog	2015-05-06 22:55:09 UTC (rev 183895)
@@ -1,3 +1,19 @@
+2015-05-06  Jon Lee  <jon...@apple.com>
+
+        Expose more font weights for -apple-system
+        https://bugs.webkit.org/show_bug.cgi?id=144707
+
+        Reviewed by Dean Jackson.
+
+        Update to platform/mac/fast/text/systemFont.html
+
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::toNSFontWeight): New static method to map font weights to NSFontWeight constants available on
+        Yosemite and later.
+        (WebCore::fontWithFamily): Request the system font with a mapped weight on Yosemite and later.
+        * platform/spi/mac/NSFontSPI.h: Add [NSFont systemFontWithSize:weight:], and the proper NSFontWeight
+        constants.
+
 2015-05-06  Dean Jackson  <d...@apple.com>
 
         Handle backdrop views that have to tile

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


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-05-06 22:46:01 UTC (rev 183894)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-05-06 22:55:09 UTC (rev 183895)
@@ -203,6 +203,24 @@
     return appKitFontWeights[fontWeight];
 }
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+static CGFloat toNSFontWeight(FontWeight fontWeight)
+{
+    static CGFloat nsFontWeights[] = {
+        NSFontWeightUltraLight, // Values between ultra-light and thin are swapped.
+        NSFontWeightThin,
+        NSFontWeightLight,
+        NSFontWeightRegular,
+        NSFontWeightMedium,
+        NSFontWeightSemibold,
+        NSFontWeightBold,
+        NSFontWeightHeavy,
+        NSFontWeightBlack
+    };
+    return nsFontWeights[fontWeight];
+}
+#endif
+
 // Family name is somewhat of a misnomer here. We first attempt to find an exact match
 // comparing the desiredFamily to the PostScript name of the installed fonts. If that fails
 // we then do a search based on the family names of the installed fonts.
@@ -210,7 +228,11 @@
 {
     if (equalIgnoringASCIICase(family.string(), String(@"-webkit-system-font")) || equalIgnoringASCIICase(family.string(), String(@"-apple-system")) || equalIgnoringASCIICase(family.string(), String(@"-apple-system-font"))) {
         // We ignore italic for system font.
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+        return [NSFont systemFontOfSize:size weight:toNSFontWeight(weight)];
+#else
         return (weight >= FontWeight600) ? [NSFont boldSystemFontOfSize:size] : [NSFont systemFontOfSize:size];
+#endif
     }
 
     if (equalIgnoringASCIICase(family.string(), String(@"-apple-system-monospaced-numbers"))) {

Modified: trunk/Source/WebCore/platform/spi/mac/NSFontSPI.h (183894 => 183895)


--- trunk/Source/WebCore/platform/spi/mac/NSFontSPI.h	2015-05-06 22:46:01 UTC (rev 183894)
+++ trunk/Source/WebCore/platform/spi/mac/NSFontSPI.h	2015-05-06 22:55:09 UTC (rev 183895)
@@ -25,6 +25,7 @@
 
 #if USE(APPLE_INTERNAL_SDK)
 
+#import <AppKit/NSFontDescriptor_Private.h>
 #import <AppKit/NSFont_Private.h>
 
 #else
@@ -32,6 +33,20 @@
 @interface NSFont (Private)
 + (NSFont *)findFontLike:(NSFont *)aFont forCharacter:(UInt32)c inLanguage:(id) language;
 + (NSFont *)findFontLike:(NSFont *)aFont forString:(NSString *)string withRange:(NSRange)range inLanguage:(id) language;
+
++ (NSFont *)systemFontOfSize:(CGFloat)size weight:(CGFloat)weight;
 @end
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+extern const CGFloat NSFontWeightUltraLight;
+extern const CGFloat NSFontWeightThin;
+extern const CGFloat NSFontWeightLight;
+extern const CGFloat NSFontWeightRegular;
+extern const CGFloat NSFontWeightMedium;
+extern const CGFloat NSFontWeightSemibold;
+extern const CGFloat NSFontWeightBold;
+extern const CGFloat NSFontWeightHeavy;
+extern const CGFloat NSFontWeightBlack;
 #endif
+
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to