Changeset 216342 in webkit


Ignore:
Timestamp:
May 6, 2017 10:43:29 PM (7 years ago)
Author:
mmaxfield@apple.com
Message:

[Cocoa] CTFontDescriptorCreateMatchingFontDescriptor() is not case insensitive
https://bugs.webkit.org/show_bug.cgi?id=171636
<rdar://problem/30811218>

Reviewed by Dean Jackson.

Source/WebCore:

LastResort is the only name which needs to be looked up case-sensitively. We can handle
this in our existing function which handles special font names (like -apple-system) to
make sure that we always do the right thing.

Test: fast/text/lastResort.html

  • platform/graphics/ios/FontCacheIOS.mm:

(WebCore::platformFontWithFamilySpecialCase):

  • platform/graphics/mac/FontCacheMac.mm:

(WebCore::platformFontWithFamilySpecialCase):

  • platform/spi/cocoa/CoreTextSPI.h:

LayoutTests:

  • fast/text/lastResort-expected.html: Added.
  • fast/text/lastResort.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r216341 r216342  
     12017-05-06  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [Cocoa] CTFontDescriptorCreateMatchingFontDescriptor() is not case insensitive
     4        https://bugs.webkit.org/show_bug.cgi?id=171636
     5        <rdar://problem/30811218>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * fast/text/lastResort-expected.html: Added.
     10        * fast/text/lastResort.html: Added.
     11
    1122017-05-06  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r216341 r216342  
     12017-05-06  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [Cocoa] CTFontDescriptorCreateMatchingFontDescriptor() is not case insensitive
     4        https://bugs.webkit.org/show_bug.cgi?id=171636
     5        <rdar://problem/30811218>
     6
     7        Reviewed by Dean Jackson.
     8
     9        LastResort is the only name which needs to be looked up case-sensitively. We can handle
     10        this in our existing function which handles special font names (like -apple-system) to
     11        make sure that we always do the right thing.
     12
     13        Test: fast/text/lastResort.html
     14
     15        * platform/graphics/ios/FontCacheIOS.mm:
     16        (WebCore::platformFontWithFamilySpecialCase):
     17        * platform/graphics/mac/FontCacheMac.mm:
     18        (WebCore::platformFontWithFamilySpecialCase):
     19        * platform/spi/cocoa/CoreTextSPI.h:
     20
    1212017-05-06  Chris Dumez  <cdumez@apple.com>
    222
  • trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm

    r216278 r216342  
    3434#import "FontCascade.h"
    3535#import "RenderThemeIOS.h"
     36#import "SoftLinking.h"
    3637#import <wtf/HashSet.h>
    3738#import <wtf/NeverDestroyed.h>
    3839#import <wtf/RetainPtr.h>
    3940#import <wtf/text/CString.h>
     41
     42#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     43SOFT_LINK_FRAMEWORK(CoreText);
     44SOFT_LINK_MAY_FAIL(CoreText, CTFontDescriptorCreateLastResort, CTFontDescriptorRef, (), ());
     45#endif
    4046
    4147namespace WebCore {
     
    165171    }
    166172
     173    if (equalLettersIgnoringASCIICase(family, "lastresort")) {
     174#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     175        if (canLoadCTFontDescriptorCreateLastResort()) {
     176            static NeverDestroyed<RetainPtr<CTFontDescriptorRef>> lastResort = adoptCF(CTFontDescriptorCreateLastResort());
     177            return adoptCF(CTFontCreateWithFontDescriptor(lastResort.get().get(), size, nullptr));
     178        }
     179#endif
     180        // LastResort is special, so it's important to look this exact string up, and not some case-folded version.
     181        // We handle this here so any caching and case folding we do in our general text codepath is bypassed.
     182        return adoptCF(CTFontCreateWithName(CFSTR("LastResort"), size, nullptr));
     183    }
     184
    167185    return nullptr;
    168186}
  • trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm

    r216278 r216342  
    4747#import <wtf/Threading.h>
    4848#import <wtf/text/AtomicStringHash.h>
     49#endif
     50
     51#import "SoftLinking.h"
     52
     53#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
     54SOFT_LINK_FRAMEWORK(CoreText);
     55SOFT_LINK_MAY_FAIL(CoreText, CTFontDescriptorCreateLastResort, CTFontDescriptorRef, (), ());
    4956#endif
    5057
     
    112119        return toCTFont([NSFont labelFontOfSize:size]);
    113120
     121    if (equalLettersIgnoringASCIICase(family, "lastresort")) {
     122#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
     123        if (canLoadCTFontDescriptorCreateLastResort()) {
     124            static NeverDestroyed<RetainPtr<CTFontDescriptorRef>> lastResort = adoptCF(CTFontDescriptorCreateLastResort());
     125            return adoptCF(CTFontCreateWithFontDescriptor(lastResort.get().get(), size, nullptr));
     126        }
     127#endif
     128        // LastResort is special, so it's important to look this exact string up, and not some case-folded version.
     129        // We handle this here so any caching and case folding we do in our general text codepath is bypassed.
     130        return adoptCF(CTFontCreateWithName(CFSTR("LastResort"), size, nullptr));
     131    }
     132
    114133    return nullptr;
    115134}
  • trunk/Source/WebCore/platform/spi/cocoa/CoreTextSPI.h

    r216278 r216342  
    8484
    8585CTFontDescriptorRef CTFontDescriptorCreateWithAttributesAndOptions(CFDictionaryRef attributes, CTFontDescriptorOptions);
     86CTFontDescriptorRef CTFontDescriptorCreateLastResort();
    8687
    8788extern const CFStringRef kCTFontCSSWeightAttribute;
Note: See TracChangeset for help on using the changeset viewer.