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/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