| Differences between
and this patch
- a/Source/WebCore/ChangeLog +54 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2015-08-06  Myles C. Maxfield  <mmaxfield@apple.com>
2
3
        Implement font-feature-settings
4
        https://bugs.webkit.org/show_bug.cgi?id=147722
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Fonts with features are simply modeled as other fonts. Font feature
9
        information is contained within fontDescription, and our caches are
10
        sensitive to this information. Therefore, we just need to make our
11
        font lookup code honor the request to use certain features.
12
13
        This patch creates a file, FontCacheCoreText, which will be the
14
        new home of all shared OS X / iOS FontCache code. Over time, I will
15
        be moving more and more source into this file, until there is
16
        nothing left of FontCacheMac.mm and FontCacheIOS.mm. For now, the
17
        only function in this file is the code which applies font features.
18
19
        No new tests (OOPS!).
20
21
        * WebCore.xcodeproj/project.pbxproj: Add FontCacheCoreText.cpp.
22
        * css/CSSFontFaceSource.cpp:
23
        (WebCore::CSSFontFaceSource::font): Pass FontDescription data down
24
        to the webfont creation routine.
25
        * loader/cache/CachedFont.cpp:
26
        (WebCore::CachedFont::createFont): Ditto.
27
        (WebCore::CachedFont::platformDataFromCustomData): Ditto.
28
        * loader/cache/CachedFont.h:
29
        * loader/cache/CachedSVGFont.cpp:
30
        (WebCore::CachedSVGFont::platformDataFromCustomData): Ditto.
31
        * loader/cache/CachedSVGFont.h:
32
        * platform/graphics/FontCache.h:
33
        * platform/graphics/cocoa/FontCacheCoreText.cpp: Added.
34
        (WebCore::applyFontFeatureSettings): What the name says.
35
        * platform/graphics/ios/FontCacheIOS.mm:
36
        (WebCore::FontCache::getSystemFontFallbackForCharacters): Call
37
        applyFontFeatureSettings().
38
        (WebCore::FontCache::createFontPlatformData): Ditto.
39
        * platform/graphics/mac/FontCacheMac.mm:
40
        (WebCore::fontWithFamily): Ditto.
41
        (WebCore::FontCache::systemFallbackForCharacters): Ditto.
42
        (WebCore::FontCache::createFontPlatformData): Ditto.
43
        * platform/graphics/mac/FontCustomPlatformData.cpp:
44
        (WebCore::FontCustomPlatformData::fontPlatformData): Ditto.
45
        * platform/graphics/cairo/FontCustomPlatformData.h:
46
        * platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
47
        (WebCore::FontCustomPlatformData::fontPlatformData): Pass
48
        FontDescription data down to the webfont creation routine.
49
        * platform/graphics/freetype/FontPlatformData.h:
50
        * platform/graphics/freetype/FontPlatformDataFreeType.cpp: Ditto.
51
        * platform/graphics/mac/FontCustomPlatformData.h:
52
        * rendering/RenderThemeIOS.mm:
53
        (WebCore::RenderThemeIOS::updateCachedSystemFontDescription): Ditto.
54
1
2015-08-05  Filip Pizlo  <fpizlo@apple.com>
55
2015-08-05  Filip Pizlo  <fpizlo@apple.com>
2
56
3
        Lightweight locks should be adaptive
57
        Lightweight locks should be adaptive
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +4 lines
Lines 947-952 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
947
		1C2417BA1992C04100EF9938 /* SpellingDot@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C2417B91992C04100EF9938 /* SpellingDot@3x.png */; };
947
		1C2417BA1992C04100EF9938 /* SpellingDot@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C2417B91992C04100EF9938 /* SpellingDot@3x.png */; };
948
		1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */; };
948
		1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */; };
949
		1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */; };
949
		1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */; };
950
		1C3969D01B74211E002BCFA7 /* FontCacheCoreText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */; };
950
		1C6466251A12C38E0094603C /* CoreTextSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
951
		1C6466251A12C38E0094603C /* CoreTextSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
951
		1C6466281A12C4200094603C /* NSFontSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C6466271A12C3F90094603C /* NSFontSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
952
		1C6466281A12C4200094603C /* NSFontSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C6466271A12C3F90094603C /* NSFontSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
952
		1C81B95A0E97330800266E07 /* InspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C81B9560E97330800266E07 /* InspectorController.h */; settings = {ATTRIBUTES = (Private, ); }; };
953
		1C81B95A0E97330800266E07 /* InspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C81B9560E97330800266E07 /* InspectorController.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 8103-8108 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
8103
		1C2417B91992C04100EF9938 /* SpellingDot@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "SpellingDot@3x.png"; sourceTree = "<group>"; };
8104
		1C2417B91992C04100EF9938 /* SpellingDot@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "SpellingDot@3x.png"; sourceTree = "<group>"; };
8104
		1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; };
8105
		1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; };
8105
		1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageMac.cpp; sourceTree = "<group>"; };
8106
		1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageMac.cpp; sourceTree = "<group>"; };
8107
		1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCacheCoreText.cpp; sourceTree = "<group>"; };
8106
		1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreTextSPI.h; sourceTree = "<group>"; };
8108
		1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreTextSPI.h; sourceTree = "<group>"; };
8107
		1C6466271A12C3F90094603C /* NSFontSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSFontSPI.h; sourceTree = "<group>"; };
8109
		1C6466271A12C3F90094603C /* NSFontSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSFontSPI.h; sourceTree = "<group>"; };
8108
		1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; };
8110
		1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; };
Lines 21232-21237 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
21232
		B5320D68122A24E9002D1440 /* cocoa */ = {
21234
		B5320D68122A24E9002D1440 /* cocoa */ = {
21233
			isa = PBXGroup;
21235
			isa = PBXGroup;
21234
			children = (
21236
			children = (
21237
				1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */,
21235
				B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
21238
				B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
21236
				7C4EDD731A7B607800198C4D /* FontCocoa.mm */,
21239
				7C4EDD731A7B607800198C4D /* FontCocoa.mm */,
21237
				B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
21240
				B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
Lines 29961-29966 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
29961
				BCEA4888097D93020094C9E4 /* RenderThemeMac.mm in Sources */,
29964
				BCEA4888097D93020094C9E4 /* RenderThemeMac.mm in Sources */,
29962
				93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */,
29965
				93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */,
29963
				5824ABAA1AE849C8009074B7 /* RenderTreePosition.cpp in Sources */,
29966
				5824ABAA1AE849C8009074B7 /* RenderTreePosition.cpp in Sources */,
29967
				1C3969D01B74211E002BCFA7 /* FontCacheCoreText.cpp in Sources */,
29964
				E44614510CD68A3500FADA75 /* RenderVideo.cpp in Sources */,
29968
				E44614510CD68A3500FADA75 /* RenderVideo.cpp in Sources */,
29965
				BCEA4867097D93020094C9E4 /* RenderView.cpp in Sources */,
29969
				BCEA4867097D93020094C9E4 /* RenderView.cpp in Sources */,
29966
				BE20507D18A458BF0080647E /* RenderVTTCue.cpp in Sources */,
29970
				BE20507D18A458BF0080647E /* RenderVTTCue.cpp in Sources */,
- a/Source/WebCore/css/CSSFontFaceSource.cpp -1 / +1 lines
Lines 151-157 RefPtr<Font> CSSFontFaceSource::font(const FontDescription& fontDescription, boo a/Source/WebCore/css/CSSFontFaceSource.cpp_sec1
151
                if (!m_generatedOTFBuffer)
151
                if (!m_generatedOTFBuffer)
152
                    return nullptr;
152
                    return nullptr;
153
                std::unique_ptr<FontCustomPlatformData> customPlatformData = createFontCustomPlatformData(*m_generatedOTFBuffer);
153
                std::unique_ptr<FontCustomPlatformData> customPlatformData = createFontCustomPlatformData(*m_generatedOTFBuffer);
154
                font = Font::create(customPlatformData->fontPlatformData(static_cast<int>(fontDescription.computedPixelSize()), syntheticBold, syntheticItalic, fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false);
154
                font = Font::create(customPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic), true, false);
155
#else
155
#else
156
                font = Font::create(std::make_unique<SVGFontData>(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
156
                font = Font::create(std::make_unique<SVGFontData>(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic);
157
#endif
157
#endif
- a/Source/WebCore/loader/cache/CachedFont.cpp -4 / +3 lines
Lines 123-136 bool CachedFont::ensureCustomFontData(SharedBuffer* data) a/Source/WebCore/loader/cache/CachedFont.cpp_sec1
123
123
124
RefPtr<Font> CachedFont::createFont(const FontDescription& fontDescription, const AtomicString&, bool syntheticBold, bool syntheticItalic, bool)
124
RefPtr<Font> CachedFont::createFont(const FontDescription& fontDescription, const AtomicString&, bool syntheticBold, bool syntheticItalic, bool)
125
{
125
{
126
    return Font::create(platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic,
126
    return Font::create(platformDataFromCustomData(fontDescription, syntheticBold, syntheticItalic), true, false);
127
        fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false);
128
}
127
}
129
128
130
FontPlatformData CachedFont::platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode renderingMode)
129
FontPlatformData CachedFont::platformDataFromCustomData(const FontDescription& fontDescription, bool bold, bool italic)
131
{
130
{
132
    ASSERT(m_fontCustomPlatformData);
131
    ASSERT(m_fontCustomPlatformData);
133
    return m_fontCustomPlatformData->fontPlatformData(static_cast<int>(size), bold, italic, orientation, widthVariant, renderingMode);
132
    return m_fontCustomPlatformData->fontPlatformData(fontDescription, bold, italic);
134
}
133
}
135
134
136
void CachedFont::allClientsRemoved()
135
void CachedFont::allClientsRemoved()
- a/Source/WebCore/loader/cache/CachedFont.h -1 / +1 lines
Lines 53-59 public: a/Source/WebCore/loader/cache/CachedFont.h_sec1
53
    virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG);
53
    virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG);
54
54
55
protected:
55
protected:
56
    FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
56
    FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic);
57
57
58
    bool ensureCustomFontData(SharedBuffer* data);
58
    bool ensureCustomFontData(SharedBuffer* data);
59
59
- a/Source/WebCore/loader/cache/CachedSVGFont.cpp -3 / +3 lines
Lines 66-76 RefPtr<Font> CachedSVGFont::createFont(const FontDescription& fontDescription, c a/Source/WebCore/loader/cache/CachedSVGFont.cpp_sec1
66
    return nullptr;
66
    return nullptr;
67
}
67
}
68
68
69
FontPlatformData CachedSVGFont::platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode renderingMode)
69
FontPlatformData CachedSVGFont::platformDataFromCustomData(const FontDescription& fontDescription, bool bold, bool italic)
70
{
70
{
71
    if (m_externalSVGDocument)
71
    if (m_externalSVGDocument)
72
        return FontPlatformData(size, bold, italic);
72
        return FontPlatformData(fontDescription.computedPixelSize(), bold, italic);
73
    return CachedFont::platformDataFromCustomData(size, bold, italic, orientation, widthVariant, renderingMode);
73
    return CachedFont::platformDataFromCustomData(fontDescription, bold, italic);
74
}
74
}
75
75
76
bool CachedSVGFont::ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI)
76
bool CachedSVGFont::ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI)
- a/Source/WebCore/loader/cache/CachedSVGFont.h -1 / +1 lines
Lines 43-49 public: a/Source/WebCore/loader/cache/CachedSVGFont.h_sec1
43
    virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG) override;
43
    virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG) override;
44
44
45
private:
45
private:
46
    FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
46
    FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic);
47
47
48
    SVGFontElement* getSVGFontById(const String&) const;
48
    SVGFontElement* getSVGFontById(const String&) const;
49
49
- a/Source/WebCore/platform/graphics/FontCache.h -1 / +5 lines
Lines 40-46 a/Source/WebCore/platform/graphics/FontCache.h_sec1
40
#include <wtf/text/AtomicStringHash.h>
40
#include <wtf/text/AtomicStringHash.h>
41
#include <wtf/text/WTFString.h>
41
#include <wtf/text/WTFString.h>
42
42
43
#if PLATFORM(IOS)
43
#if PLATFORM(COCOA)
44
#include <CoreText/CTFont.h>
44
#include <CoreText/CTFont.h>
45
#endif
45
#endif
46
46
Lines 200-205 private: a/Source/WebCore/platform/graphics/FontCache.h_sec2
200
    friend class Font;
200
    friend class Font;
201
};
201
};
202
202
203
#if PLATFORM(COCOA)
204
RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef, const FontFeatureSettings&);
205
#endif
206
203
#if !PLATFORM(MAC)
207
#if !PLATFORM(MAC)
204
inline void FontCache::platformPurgeInactiveFontData()
208
inline void FontCache::platformPurgeInactiveFontData()
205
{
209
{
- a/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h -1 / +2 lines
Lines 33-38 typedef struct _cairo_font_face cairo_font_face_t; a/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h_sec1
33
33
34
namespace WebCore {
34
namespace WebCore {
35
35
36
class FontDescription;
36
class FontPlatformData;
37
class FontPlatformData;
37
class SharedBuffer;
38
class SharedBuffer;
38
39
Lines 41-47 struct FontCustomPlatformData { a/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h_sec2
41
public:
42
public:
42
    FontCustomPlatformData(FT_Face, SharedBuffer&);
43
    FontCustomPlatformData(FT_Face, SharedBuffer&);
43
    ~FontCustomPlatformData();
44
    ~FontCustomPlatformData();
44
    FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
45
    FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic);
45
    static bool supportsFormat(const String&);
46
    static bool supportsFormat(const String&);
46
47
47
private:
48
private:
- a/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp +58 lines
Line 0 a/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp_sec1
1
/*
2
 * Copyright (C) 2015 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#import "config.h"
27
#import "FontCache.h"
28
29
namespace WebCore {
30
31
static inline void appendFeature(CFMutableArrayRef features, const FontFeature& feature, CFStringRef featureDictionaryKeys[2])
32
{
33
    RetainPtr<CFStringRef> featureKey = feature.tag().string().createCFString();
34
    int rawFeatureValue = feature.value();
35
    RetainPtr<CFNumberRef> featureValue = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &rawFeatureValue));
36
    CFTypeRef featureDictionaryValues[] = {featureKey.get(), featureValue.get()};
37
    RetainPtr<CFDictionaryRef> featureDictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)featureDictionaryKeys, featureDictionaryValues, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
38
    CFArrayAppendValue(features, featureDictionary.get());
39
}
40
41
RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef originalFont, const FontFeatureSettings& features)
42
{
43
    RetainPtr<CFMutableArrayRef> featureArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, features.size(), &kCFTypeArrayCallBacks));
44
    CFStringRef trueTypeFeatureDictionaryKeys[] = {kCTFontFeatureTypeIdentifierKey, kCTFontFeatureSelectorIdentifierKey};
45
    for (size_t i = 0; i < features.size(); ++i) {
46
        appendFeature(featureArray.get(), features[i], trueTypeFeatureDictionaryKeys);
47
#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000)
48
        CFStringRef openTypeFeatureDictionaryKeys[] = {kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureValue};
49
        appendFeature(featureArray.get(), features[i], openTypeFeatureDictionaryKeys);
50
#endif
51
    }
52
    CFArrayRef featureArrayPtr = featureArray.get();
53
    RetainPtr<CFDictionaryRef> dictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)&kCTFontFeatureSettingsAttribute, (const void**)&featureArrayPtr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
54
    RetainPtr<CTFontDescriptorRef> descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(dictionary.get()));
55
    return adoptCF(CTFontCreateCopyWithAttributes(originalFont, CTFontGetSize(originalFont), nullptr, descriptor.get()));
56
}
57
58
}
- a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp -2 / +2 lines
Lines 68-76 FontCustomPlatformData::~FontCustomPlatformData() a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp_sec1
68
    cairo_font_face_destroy(m_fontFace);
68
    cairo_font_face_destroy(m_fontFace);
69
}
69
}
70
70
71
FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant, FontRenderingMode)
71
FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& description, bool bold, bool italic)
72
{
72
{
73
    return FontPlatformData(m_fontFace, size, bold, italic, orientation);
73
    return FontPlatformData(m_fontFace, description, bold, italic);
74
}
74
}
75
75
76
std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer)
76
std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer)
- a/Source/WebCore/platform/graphics/freetype/FontPlatformData.h -1 / +1 lines
Lines 63-69 public: a/Source/WebCore/platform/graphics/freetype/FontPlatformData.h_sec1
63
        { }
63
        { }
64
64
65
    FontPlatformData(FcPattern*, const FontDescription&);
65
    FontPlatformData(FcPattern*, const FontDescription&);
66
    FontPlatformData(cairo_font_face_t*, float size, bool bold, bool italic, FontOrientation);
66
    FontPlatformData(cairo_font_face_t*, const FontDescription&, bool bold, bool italic);
67
    FontPlatformData(float size, bool bold, bool italic);
67
    FontPlatformData(float size, bool bold, bool italic);
68
    FontPlatformData(const FontPlatformData&);
68
    FontPlatformData(const FontPlatformData&);
69
    FontPlatformData(const FontPlatformData&, float size);
69
    FontPlatformData(const FontPlatformData&, float size);
- a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp -3 / +3 lines
Lines 187-200 FontPlatformData::FontPlatformData(float size, bool bold, bool italic) a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp_sec1
187
    // We cannot create a scaled font here.
187
    // We cannot create a scaled font here.
188
}
188
}
189
189
190
FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic, FontOrientation orientation)
190
FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, const FontDescription& description, bool bold, bool italic)
191
    : m_fallbacks(nullptr)
191
    : m_fallbacks(nullptr)
192
    , m_size(size)
192
    , m_size(description.computedPixelSize())
193
    , m_syntheticBold(bold)
193
    , m_syntheticBold(bold)
194
    , m_syntheticOblique(italic)
194
    , m_syntheticOblique(italic)
195
    , m_fixedWidth(false)
195
    , m_fixedWidth(false)
196
    , m_scaledFont(nullptr)
196
    , m_scaledFont(nullptr)
197
    , m_orientation(orientation)
197
    , m_orientation(description.orientation())
198
{
198
{
199
    buildScaledFont(fontFace);
199
    buildScaledFont(fontFace);
200
200
- a/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp -3 / +4 lines
Lines 103-113 void Font::platformCharWidthInit() a/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp_sec1
103
PassRefPtr<Font> Font::platformCreateScaledFont(const FontDescription& fontDescription, float scaleFactor) const
103
PassRefPtr<Font> Font::platformCreateScaledFont(const FontDescription& fontDescription, float scaleFactor) const
104
{
104
{
105
    ASSERT(m_platformData.scaledFont());
105
    ASSERT(m_platformData.scaledFont());
106
    FontDescription scaledFontDescription = fontDescription;
107
    scaledFontDescription.setComputedSize(scaleFactor * fontDescription.computedSize());
106
    return Font::create(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()),
108
    return Font::create(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()),
107
        scaleFactor * fontDescription.computedSize(),
109
        scaledFontDescription,
108
        m_platformData.syntheticBold(),
110
        m_platformData.syntheticBold(),
109
        m_platformData.syntheticOblique(),
111
        m_platformData.syntheticOblique()),
110
        fontDescription.orientation()),
111
        isCustomFont(), false);
112
        isCustomFont(), false);
112
}
113
}
113
114
- a/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm +6 lines
Lines 85-90 PassRefPtr<Font> FontCache::getSystemFontFallbackForCharacters(const FontDescrip a/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm_sec1
85
    if (!substituteFont)
85
    if (!substituteFont)
86
        return nullptr;
86
        return nullptr;
87
87
88
    if (substituteFont && description.featureSettings() && description.featureSettings()->size())
89
        substituteFont = applyFontFeatureSettings(substituteFont.get(), *description.featureSettings());
90
88
    CTFontSymbolicTraits originalTraits = CTFontGetSymbolicTraits(ctFont);
91
    CTFontSymbolicTraits originalTraits = CTFontGetSymbolicTraits(ctFont);
89
    CTFontSymbolicTraits actualTraits = 0;
92
    CTFontSymbolicTraits actualTraits = 0;
90
    if (isFontWeightBold(description.weight()) || description.italic())
93
    if (isFontWeightBold(description.weight()) || description.italic())
Lines 699-704 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe a/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm_sec2
699
    if (!ctFont)
702
    if (!ctFont)
700
        return nullptr;
703
        return nullptr;
701
704
705
    if (ctFont && fontDescription.featureSettings() && fontDescription.featureSettings()->size())
706
        ctFont = applyFontFeatureSettings(ctFont.get(), *fontDescription.featureSettings());
707
702
    CTFontSymbolicTraits actualTraits = 0;
708
    CTFontSymbolicTraits actualTraits = 0;
703
    if (isFontWeightBold(fontDescription.weight()) || fontDescription.italic())
709
    if (isFontWeightBold(fontDescription.weight()) || fontDescription.italic())
704
        actualTraits = CTFontGetSymbolicTraits(ctFont.get());
710
        actualTraits = CTFontGetSymbolicTraits(ctFont.get());
- a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm -4 / +11 lines
Lines 264-270 static Optional<NSFont*> fontWithFamilySpecialCase(const AtomicString& family, F a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec1
264
// Family name is somewhat of a misnomer here. We first attempt to find an exact match
264
// Family name is somewhat of a misnomer here. We first attempt to find an exact match
265
// comparing the desiredFamily to the PostScript name of the installed fonts. If that fails
265
// comparing the desiredFamily to the PostScript name of the installed fonts. If that fails
266
// we then do a search based on the family names of the installed fonts.
266
// we then do a search based on the family names of the installed fonts.
267
static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, float size)
267
static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, const FontFeatureSettings* featureSettings, float size)
268
{
268
{
269
    if (const auto& specialCase = fontWithFamilySpecialCase(family, weight, desiredTraits, size))
269
    if (const auto& specialCase = fontWithFamilySpecialCase(family, weight, desiredTraits, size))
270
        return specialCase.value();
270
        return specialCase.value();
Lines 286-297 static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desire a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec2
286
        requestedTraits |= kCTFontBoldTrait;
286
        requestedTraits |= kCTFontBoldTrait;
287
287
288
    NSString *desiredFamily = family;
288
    NSString *desiredFamily = family;
289
    font = CFBridgingRelease(CTFontCreateForCSS((CFStringRef)desiredFamily, toCoreTextFontWeight(weight), requestedTraits, size));
289
    RetainPtr<CTFontRef> foundFont = adoptCF(CTFontCreateForCSS((CFStringRef)desiredFamily, toCoreTextFontWeight(weight), requestedTraits, size));
290
    if (foundFont && featureSettings && featureSettings->size())
291
        foundFont = applyFontFeatureSettings(foundFont.get(), *featureSettings);
292
    font = CFBridgingRelease(CFRetain(foundFont.get()));
290
    availableFamily = [font familyName];
293
    availableFamily = [font familyName];
291
    chosenWeight = [fontManager weightOfFont:font];
294
    chosenWeight = [fontManager weightOfFont:font];
292
295
293
#else
296
#else
294
297
298
    UNUSED_PARAM(featureSettings);
299
295
    NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (weight >= FontWeight600 ? NSBoldFontMask : 0);
300
    NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (weight >= FontWeight600 ? NSBoldFontMask : 0);
296
    if (hasDesiredFamilyToAvailableFamilyMapping(family, desiredTraitsForNameMatch, availableFamily)) {
301
    if (hasDesiredFamilyToAvailableFamilyMapping(family, desiredTraitsForNameMatch, availableFamily)) {
297
        if (!availableFamily) {
302
        if (!availableFamily) {
Lines 506-511 RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& descr a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec3
506
    const FontPlatformData& platformData = originalFontData->platformData();
511
    const FontPlatformData& platformData = originalFontData->platformData();
507
    NSFont *nsFont = platformData.nsFont();
512
    NSFont *nsFont = platformData.nsFont();
508
    RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), characters, length);
513
    RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), characters, length);
514
    if (result && description.featureSettings() && description.featureSettings()->size())
515
        result = applyFontFeatureSettings(result.get(), *description.featureSettings());
509
    if (!result)
516
    if (!result)
510
        return nullptr;
517
        return nullptr;
511
518
Lines 664-670 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec4
664
    NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0;
671
    NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0;
665
    float size = fontDescription.computedPixelSize();
672
    float size = fontDescription.computedPixelSize();
666
673
667
    NSFont *nsFont = fontWithFamily(family, traits, fontDescription.weight(), size);
674
    NSFont *nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), size);
668
    if (!nsFont) {
675
    if (!nsFont) {
669
        if (!shouldAutoActivateFontIfNeeded(family))
676
        if (!shouldAutoActivateFontIfNeeded(family))
670
            return nullptr;
677
            return nullptr;
Lines 673-679 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm_sec5
673
        // Ignore the result because we want to use our own algorithm to actually find the font.
680
        // Ignore the result because we want to use our own algorithm to actually find the font.
674
        [NSFont fontWithName:family size:size];
681
        [NSFont fontWithName:family size:size];
675
682
676
        nsFont = fontWithFamily(family, traits, fontDescription.weight(), size);
683
        nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), size);
677
        if (!nsFont)
684
        if (!nsFont)
678
            return nullptr;
685
            return nullptr;
679
    }
686
    }
- a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp -2 / +10 lines
Lines 21-26 a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp_sec1
21
#include "config.h"
21
#include "config.h"
22
#include "FontCustomPlatformData.h"
22
#include "FontCustomPlatformData.h"
23
23
24
#include "FontCache.h"
24
#include "FontPlatformData.h"
25
#include "FontPlatformData.h"
25
#include "SharedBuffer.h"
26
#include "SharedBuffer.h"
26
#include <CoreGraphics/CoreGraphics.h>
27
#include <CoreGraphics/CoreGraphics.h>
Lines 32-41 FontCustomPlatformData::~FontCustomPlatformData() a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp_sec2
32
{
33
{
33
}
34
}
34
35
35
FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode)
36
FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic)
36
{
37
{
38
    int size = fontDescription.computedPixelSize();
39
    FontOrientation orientation = fontDescription.orientation();
40
    FontWidthVariant widthVariant = fontDescription.widthVariant();
37
#if CORETEXT_WEB_FONTS
41
#if CORETEXT_WEB_FONTS
38
    return FontPlatformData(adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr)).get(), size, bold, italic, orientation, widthVariant);
42
    RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
43
    if (font && fontDescription.featureSettings() && fontDescription.featureSettings()->size())
44
        font = applyFontFeatureSettings(font.get(), *fontDescription.featureSettings());
45
    return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant);
46
39
#else
47
#else
40
    return FontPlatformData(m_cgFont.get(), size, bold, italic, orientation, widthVariant);
48
    return FontPlatformData(m_cgFont.get(), size, bold, italic, orientation, widthVariant);
41
#endif
49
#endif
- a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h -1 / +2 lines
Lines 21-26 a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h_sec1
21
#ifndef FontCustomPlatformData_h
21
#ifndef FontCustomPlatformData_h
22
#define FontCustomPlatformData_h
22
#define FontCustomPlatformData_h
23
23
24
#include "FontDescription.h"
24
#include "TextFlags.h"
25
#include "TextFlags.h"
25
#include <CoreFoundation/CFBase.h>
26
#include <CoreFoundation/CFBase.h>
26
#include <wtf/Forward.h>
27
#include <wtf/Forward.h>
Lines 50-56 public: a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h_sec2
50
51
51
    ~FontCustomPlatformData();
52
    ~FontCustomPlatformData();
52
53
53
    FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
54
    FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic);
54
55
55
    static bool supportsFormat(const String&);
56
    static bool supportsFormat(const String&);
56
57
- a/Source/WebCore/rendering/RenderThemeIOS.mm +2 lines
Lines 1261-1266 void RenderThemeIOS::updateCachedSystemFontDescription(CSSValueID valueID, FontD a/Source/WebCore/rendering/RenderThemeIOS.mm_sec1
1261
1261
1262
    ASSERT(fontDescriptor);
1262
    ASSERT(fontDescriptor);
1263
    RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr));
1263
    RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr));
1264
    if (font && fontDescription.featureSettings() && fontDescription.featureSettings()->size())
1265
        font = applyFontFeatureSettings(font.get(), *fontDescription.featureSettings());
1264
    fontDescription.setIsAbsoluteSize(true);
1266
    fontDescription.setIsAbsoluteSize(true);
1265
    fontDescription.setOneFamily(textStyle);
1267
    fontDescription.setOneFamily(textStyle);
1266
    fontDescription.setSpecifiedSize(CTFontGetSize(font.get()));
1268
    fontDescription.setSpecifiedSize(CTFontGetSize(font.get()));

Return to Bug 147722