| Differences between
and this patch
- a/Source/WebCore/ChangeLog +48 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/mac/FontCustomPlatformData.h:
46
        * rendering/RenderThemeIOS.mm:
47
        (WebCore::RenderThemeIOS::updateCachedSystemFontDescription): Ditto.
48
1
2015-08-06  Chris Dumez  <cdumez@apple.com>
49
2015-08-06  Chris Dumez  <cdumez@apple.com>
2
50
3
        Toggle GPS state based on page visibility to save battery
51
        Toggle GPS state based on page visibility to save battery
- 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 8105-8110 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
8105
		1C2417B91992C04100EF9938 /* SpellingDot@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "SpellingDot@3x.png"; sourceTree = "<group>"; };
8106
		1C2417B91992C04100EF9938 /* SpellingDot@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "SpellingDot@3x.png"; sourceTree = "<group>"; };
8106
		1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; };
8107
		1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; };
8107
		1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageMac.cpp; sourceTree = "<group>"; };
8108
		1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageMac.cpp; sourceTree = "<group>"; };
8109
		1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCacheCoreText.cpp; sourceTree = "<group>"; };
8108
		1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreTextSPI.h; sourceTree = "<group>"; };
8110
		1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreTextSPI.h; sourceTree = "<group>"; };
8109
		1C6466271A12C3F90094603C /* NSFontSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSFontSPI.h; sourceTree = "<group>"; };
8111
		1C6466271A12C3F90094603C /* NSFontSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSFontSPI.h; sourceTree = "<group>"; };
8110
		1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; };
8112
		1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; };
Lines 21238-21243 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
21238
		B5320D68122A24E9002D1440 /* cocoa */ = {
21240
		B5320D68122A24E9002D1440 /* cocoa */ = {
21239
			isa = PBXGroup;
21241
			isa = PBXGroup;
21240
			children = (
21242
			children = (
21243
				1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */,
21241
				B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
21244
				B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
21242
				7C4EDD731A7B607800198C4D /* FontCocoa.mm */,
21245
				7C4EDD731A7B607800198C4D /* FontCocoa.mm */,
21243
				B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
21246
				B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
Lines 29968-29973 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
29968
				BCEA4888097D93020094C9E4 /* RenderThemeMac.mm in Sources */,
29971
				BCEA4888097D93020094C9E4 /* RenderThemeMac.mm in Sources */,
29969
				93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */,
29972
				93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */,
29970
				5824ABAA1AE849C8009074B7 /* RenderTreePosition.cpp in Sources */,
29973
				5824ABAA1AE849C8009074B7 /* RenderTreePosition.cpp in Sources */,
29974
				1C3969D01B74211E002BCFA7 /* FontCacheCoreText.cpp in Sources */,
29971
				E44614510CD68A3500FADA75 /* RenderVideo.cpp in Sources */,
29975
				E44614510CD68A3500FADA75 /* RenderVideo.cpp in Sources */,
29972
				BCEA4867097D93020094C9E4 /* RenderView.cpp in Sources */,
29976
				BCEA4867097D93020094C9E4 /* RenderView.cpp in Sources */,
29973
				BE20507D18A458BF0080647E /* RenderVTTCue.cpp in Sources */,
29977
				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 39-45 a/Source/WebCore/platform/graphics/FontCache.h_sec1
39
#include <wtf/Vector.h>
39
#include <wtf/Vector.h>
40
#include <wtf/text/WTFString.h>
40
#include <wtf/text/WTFString.h>
41
41
42
#if PLATFORM(IOS)
42
#if PLATFORM(COCOA)
43
#include <CoreText/CTFont.h>
43
#include <CoreText/CTFont.h>
44
#endif
44
#endif
45
45
Lines 185-190 private: a/Source/WebCore/platform/graphics/FontCache.h_sec2
185
    friend class Font;
185
    friend class Font;
186
};
186
};
187
187
188
#if PLATFORM(COCOA)
189
RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef, const FontFeatureSettings&);
190
#endif
191
188
#if !PLATFORM(MAC)
192
#if !PLATFORM(MAC)
189
inline void FontCache::platformPurgeInactiveFontData()
193
inline void FontCache::platformPurgeInactiveFontData()
190
{
194
{
- a/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp +50 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
RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef originalFont, const FontFeatureSettings& features)
32
{
33
    RetainPtr<CFMutableArrayRef> featureArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, features.size(), &kCFTypeArrayCallBacks));
34
    CFStringRef featureDictionaryKeys[] = {kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureValue};
35
    for (size_t i = 0; i < features.size(); ++i) {
36
        const auto& feature = features[i];
37
        RetainPtr<CFStringRef> featureKey = feature.tag().string().createCFString();
38
        int rawFeatureValue = feature.value();
39
        RetainPtr<CFNumberRef> featureValue = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &rawFeatureValue));
40
        CFTypeRef featureDictionaryValues[] = {featureKey.get(), featureValue.get()};
41
        RetainPtr<CFDictionaryRef> featureDictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)featureDictionaryKeys, featureDictionaryValues, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
42
        CFArrayAppendValue(featureArray.get(), featureDictionary.get());
43
    }
44
    CFArrayRef featureArrayPtr = featureArray.get();
45
    RetainPtr<CFDictionaryRef> dictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)&kCTFontFeatureSettingsAttribute, (const void**)&featureArrayPtr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
46
    RetainPtr<CTFontDescriptorRef> descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(dictionary.get()));
47
    return adoptCF(CTFontCreateCopyWithAttributes(originalFont, CTFontGetSize(originalFont), nullptr, descriptor.get()));
48
}
49
50
}
- 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 (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 (fontDescription.featureSettings() && description.featureSettings()->size())
706
        ctFont = applyFontFeatureSettings(ctFont.get(), *description.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 / +9 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-292 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 (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
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();
509
    const FontPlatformData& platformData = originalFontData->platformData();
507
    NSFont *nsFont = platformData.nsFont();
510
    NSFont *nsFont = platformData.nsFont();
508
    RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), characters, length);
511
    RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), characters, length);
512
    if (description.featureSettings() && description.featureSettings()->size())
513
        result = applyFontFeatureSettings(result.get(), *description.featureSettings());
509
    if (!result)
514
    if (!result)
510
        return nullptr;
515
        return nullptr;
511
516
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;
669
    NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0;
665
    float size = fontDescription.computedPixelSize();
670
    float size = fontDescription.computedPixelSize();
666
671
667
    NSFont *nsFont = fontWithFamily(family, traits, fontDescription.weight(), size);
672
    NSFont *nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), size);
668
    if (!nsFont) {
673
    if (!nsFont) {
669
        if (!shouldAutoActivateFontIfNeeded(family))
674
        if (!shouldAutoActivateFontIfNeeded(family))
670
            return nullptr;
675
            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.
678
        // Ignore the result because we want to use our own algorithm to actually find the font.
674
        [NSFont fontWithName:family size:size];
679
        [NSFont fontWithName:family size:size];
675
680
676
        nsFont = fontWithFamily(family, traits, fontDescription.weight(), size);
681
        nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), size);
677
        if (!nsFont)
682
        if (!nsFont)
678
            return nullptr;
683
            return nullptr;
679
    }
684
    }
- 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 (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 (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