⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 183895 in webkit


Ignore:
Timestamp:
May 6, 2015, 3:55:09 PM (11 years ago)
Author:
jonlee@apple.com
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.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r183894 r183895  
     12015-05-06  Jon Lee  <jonlee@apple.com>
     2
     3        Expose more font weights for -apple-system
     4        https://bugs.webkit.org/show_bug.cgi?id=144707
     5
     6        Reviewed by Dean Jackson.
     7
     8        * platform/mac/fast/text/systemFont.html: Update test to include font weights for -apple-system.
     9        * platform/mac/fast/text/systemFont-expected.txt: Update expectations.
     10
    1112015-05-06  Dean Jackson  <dino@apple.com>
    212
  • trunk/LayoutTests/platform/mac/fast/text/systemFont-expected.txt

    r183662 r183895  
    1 layer at (0,0) size 785x2036
     1layer at (0,0) size 785x2198
    22  RenderView at (0,0) size 785x600
    3 layer at (0,0) size 785x2036
    4   RenderBlock {HTML} at (0,0) size 785x2036
    5     RenderBody {BODY} at (8,8) size 769x2020
     3layer at (0,0) size 785x2198
     4  RenderBlock {HTML} at (0,0) size 785x2198
     5    RenderBody {BODY} at (8,8) size 769x2182
    66      RenderBlock {DIV} at (0,0) size 769x897
    77        RenderBlock {DIV} at (0,0) size 769x28
     
    7979            text run at (0,0) width 756: "This is a test for -apple-"
    8080            text run at (0,85) width 373: "system font"
    81       RenderBlock {DIV} at (0,1738) size 769x282
     81      RenderBlock {DIV} at (0,1738) size 769x162
     82        RenderBlock {DIV} at (0,0) size 769x18
     83          RenderText {#text} at (0,0) size 302x18
     84            text run at (0,0) width 302: "This is a font weight test for -apple-system font"
     85        RenderBlock {DIV} at (0,18) size 769x18
     86          RenderText {#text} at (0,0) size 316x18
     87            text run at (0,0) width 316: "This is a font weight test for -apple-system font"
     88        RenderBlock {DIV} at (0,36) size 769x18
     89          RenderText {#text} at (0,0) size 335x18
     90            text run at (0,0) width 335: "This is a font weight test for -apple-system font"
     91        RenderBlock {DIV} at (0,54) size 769x18
     92          RenderText {#text} at (0,0) size 350x18
     93            text run at (0,0) width 350: "This is a font weight test for -apple-system font"
     94        RenderBlock {DIV} at (0,72) size 769x18
     95          RenderText {#text} at (0,0) size 362x18
     96            text run at (0,0) width 362: "This is a font weight test for -apple-system font"
     97        RenderBlock {DIV} at (0,90) size 769x18
     98          RenderText {#text} at (0,0) size 374x18
     99            text run at (0,0) width 374: "This is a font weight test for -apple-system font"
     100        RenderBlock {DIV} at (0,108) size 769x18
     101          RenderText {#text} at (0,0) size 374x18
     102            text run at (0,0) width 374: "This is a font weight test for -apple-system font"
     103        RenderBlock {DIV} at (0,126) size 769x18
     104          RenderText {#text} at (0,0) size 396x18
     105            text run at (0,0) width 396: "This is a font weight test for -apple-system font"
     106        RenderBlock {DIV} at (0,144) size 769x18
     107          RenderText {#text} at (0,0) size 396x18
     108            text run at (0,0) width 396: "This is a font weight test for -apple-system font"
     109      RenderBlock {DIV} at (0,1900) size 769x282
    82110        RenderBlock {DIV} at (0,0) size 769x56
    83111          RenderText {#text} at (0,0) size 644x56
  • trunk/LayoutTests/platform/mac/fast/text/systemFont.html

    r183662 r183895  
    2525    </div>
    2626    <div>
     27        <div style="font-family: -apple-system; font-weight: 100">This is a font weight test for -apple-system font</div>
     28        <div style="font-family: -apple-system; font-weight: 200">This is a font weight test for -apple-system font</div>
     29        <div style="font-family: -apple-system; font-weight: 300">This is a font weight test for -apple-system font</div>
     30        <div style="font-family: -apple-system; font-weight: 400">This is a font weight test for -apple-system font</div>
     31        <div style="font-family: -apple-system; font-weight: 500">This is a font weight test for -apple-system font</div>
     32        <div style="font-family: -apple-system; font-weight: 600">This is a font weight test for -apple-system font</div>
     33        <div style="font-family: -apple-system; font-weight: 700">This is a font weight test for -apple-system font</div>
     34        <div style="font-family: -apple-system; font-weight: 800">This is a font weight test for -apple-system font</div>
     35        <div style="font-family: -apple-system; font-weight: 900">This is a font weight test for -apple-system font</div>
     36    </div>
     37    <div>
    2738        <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>
    2839        <div style="font: 30.0px '-apple-system-monospaced-numbers'">This is a test for -apple-system-monospaced-numbers font - 00:11:22:33</div>
  • trunk/Source/WebCore/ChangeLog

    r183894 r183895  
     12015-05-06  Jon Lee  <jonlee@apple.com>
     2
     3        Expose more font weights for -apple-system
     4        https://bugs.webkit.org/show_bug.cgi?id=144707
     5
     6        Reviewed by Dean Jackson.
     7
     8        Update to platform/mac/fast/text/systemFont.html
     9
     10        * platform/graphics/mac/FontCacheMac.mm:
     11        (WebCore::toNSFontWeight): New static method to map font weights to NSFontWeight constants available on
     12        Yosemite and later.
     13        (WebCore::fontWithFamily): Request the system font with a mapped weight on Yosemite and later.
     14        * platform/spi/mac/NSFontSPI.h: Add [NSFont systemFontWithSize:weight:], and the proper NSFontWeight
     15        constants.
     16
    1172015-05-06  Dean Jackson  <dino@apple.com>
    218
  • trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm

    r183662 r183895  
    204204}
    205205
     206#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     207static CGFloat toNSFontWeight(FontWeight fontWeight)
     208{
     209    static CGFloat nsFontWeights[] = {
     210        NSFontWeightUltraLight, // Values between ultra-light and thin are swapped.
     211        NSFontWeightThin,
     212        NSFontWeightLight,
     213        NSFontWeightRegular,
     214        NSFontWeightMedium,
     215        NSFontWeightSemibold,
     216        NSFontWeightBold,
     217        NSFontWeightHeavy,
     218        NSFontWeightBlack
     219    };
     220    return nsFontWeights[fontWeight];
     221}
     222#endif
     223
    206224// Family name is somewhat of a misnomer here. We first attempt to find an exact match
    207225// comparing the desiredFamily to the PostScript name of the installed fonts. If that fails
     
    211229    if (equalIgnoringASCIICase(family.string(), String(@"-webkit-system-font")) || equalIgnoringASCIICase(family.string(), String(@"-apple-system")) || equalIgnoringASCIICase(family.string(), String(@"-apple-system-font"))) {
    212230        // We ignore italic for system font.
     231#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     232        return [NSFont systemFontOfSize:size weight:toNSFontWeight(weight)];
     233#else
    213234        return (weight >= FontWeight600) ? [NSFont boldSystemFontOfSize:size] : [NSFont systemFontOfSize:size];
     235#endif
    214236    }
    215237
  • trunk/Source/WebCore/platform/spi/mac/NSFontSPI.h

    r176112 r183895  
    2626#if USE(APPLE_INTERNAL_SDK)
    2727
     28#import <AppKit/NSFontDescriptor_Private.h>
    2829#import <AppKit/NSFont_Private.h>
    2930
     
    3334+ (NSFont *)findFontLike:(NSFont *)aFont forCharacter:(UInt32)c inLanguage:(id) language;
    3435+ (NSFont *)findFontLike:(NSFont *)aFont forString:(NSString *)string withRange:(NSRange)range inLanguage:(id) language;
     36
     37+ (NSFont *)systemFontOfSize:(CGFloat)size weight:(CGFloat)weight;
    3538@end
    3639
     40#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     41extern const CGFloat NSFontWeightUltraLight;
     42extern const CGFloat NSFontWeightThin;
     43extern const CGFloat NSFontWeightLight;
     44extern const CGFloat NSFontWeightRegular;
     45extern const CGFloat NSFontWeightMedium;
     46extern const CGFloat NSFontWeightSemibold;
     47extern const CGFloat NSFontWeightBold;
     48extern const CGFloat NSFontWeightHeavy;
     49extern const CGFloat NSFontWeightBlack;
    3750#endif
     51
     52#endif
Note: See TracChangeset for help on using the changeset viewer.