WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-147722-20150807022556.patch (text/plain), 18.33 KB, created by
Myles C. Maxfield
on 2015-08-07 02:26:06 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2015-08-07 02:26:06 PDT
Size:
18.33 KB
patch
obsolete
>Subversion Revision: 188120 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 9a2a7b81bdae9bc2707f0899547c16eb75e093d0..d794fa4fb554167846300d5d67412ee98a3a4b37 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,44 @@ >+2015-08-07 Myles C. Maxfield <mmaxfield@apple.com> >+ >+ Implement font-feature-settings >+ https://bugs.webkit.org/show_bug.cgi?id=147722 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Fonts with features are simply modeled as new font objects. Font >+ feature information is contained within FontDescription, and our >+ caches are correctly sensitive to this information. Therefore, >+ we just need to make our font lookup code honor the request to >+ use certain features. >+ >+ This patch creates a file, FontCacheCoreText.cpp, which will be the >+ new home of all shared OS X / iOS FontCache code. Over time, I will >+ be moving more and more source into this file, until there is >+ nothing left of FontCacheMac.mm and FontCacheIOS.mm. For now, the >+ only function in this file is the code which applies font features. >+ >+ Tests are forthcoming. >+ >+ * WebCore.xcodeproj/project.pbxproj: Add FontCacheCoreText.cpp. >+ * platform/graphics/FontCache.h: >+ * platform/graphics/cocoa/FontCacheCoreText.cpp: Added. >+ (WebCore::appendTrueTypeFeature): What the name says. >+ (WebCore::appendOpenTypeFeature): Ditto. >+ (WebCore::applyFontFeatureSettings): Ditto. >+ * platform/graphics/ios/FontCacheIOS.mm: >+ (WebCore::FontCache::getSystemFontFallbackForCharacters): Call >+ applyFontFeatureSettings(). >+ (WebCore::FontCache::createFontPlatformData): Ditto. >+ * platform/graphics/mac/FontCacheMac.mm: >+ (WebCore::fontWithFamily): Ditto. >+ (WebCore::FontCache::systemFallbackForCharacters): Ditto. >+ (WebCore::FontCache::createFontPlatformData): Ditto. >+ * platform/graphics/mac/FontCustomPlatformData.cpp: >+ (WebCore::FontCustomPlatformData::fontPlatformData): Ditto. >+ * rendering/RenderThemeIOS.mm: >+ (WebCore::RenderThemeIOS::updateCachedSystemFontDescription): >+ Ditto. >+ > 2015-08-07 Doug Russell <d_russell@apple.com> > > AX: Bug 147737 is causing test failures in Mavericks WK1 >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index c540d8a493b04503dba80b23a1bd2f0b9ecb9c5e..d371ac542bcff19851067a217d49e7d9a32e7962 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -947,6 +947,7 @@ > 1C2417BA1992C04100EF9938 /* SpellingDot@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C2417B91992C04100EF9938 /* SpellingDot@3x.png */; }; > 1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */; }; > 1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */; }; >+ 1C3969D01B74211E002BCFA7 /* FontCacheCoreText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */; }; > 1C6466251A12C38E0094603C /* CoreTextSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 1C6466281A12C4200094603C /* NSFontSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C6466271A12C3F90094603C /* NSFontSPI.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 1C81B95A0E97330800266E07 /* InspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C81B9560E97330800266E07 /* InspectorController.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -8103,6 +8104,7 @@ > 1C2417B91992C04100EF9938 /* SpellingDot@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "SpellingDot@3x.png"; sourceTree = "<group>"; }; > 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = "<group>"; }; > 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageMac.cpp; sourceTree = "<group>"; }; >+ 1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCacheCoreText.cpp; sourceTree = "<group>"; }; > 1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreTextSPI.h; sourceTree = "<group>"; }; > 1C6466271A12C3F90094603C /* NSFontSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSFontSPI.h; sourceTree = "<group>"; }; > 1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; }; >@@ -21232,6 +21234,7 @@ > B5320D68122A24E9002D1440 /* cocoa */ = { > isa = PBXGroup; > children = ( >+ 1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */, > B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */, > 7C4EDD731A7B607800198C4D /* FontCocoa.mm */, > B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */, >@@ -29961,6 +29964,7 @@ > BCEA4888097D93020094C9E4 /* RenderThemeMac.mm in Sources */, > 93F19AD508245E59001E9ABC /* RenderTreeAsText.cpp in Sources */, > 5824ABAA1AE849C8009074B7 /* RenderTreePosition.cpp in Sources */, >+ 1C3969D01B74211E002BCFA7 /* FontCacheCoreText.cpp in Sources */, > E44614510CD68A3500FADA75 /* RenderVideo.cpp in Sources */, > BCEA4867097D93020094C9E4 /* RenderView.cpp in Sources */, > BE20507D18A458BF0080647E /* RenderVTTCue.cpp in Sources */, >diff --git a/Source/WebCore/platform/graphics/FontCache.h b/Source/WebCore/platform/graphics/FontCache.h >index 7134cf10556b89a4edf6c4e22f2cb96e586cdbf3..11b1ea134d0f6f3e3a7e0a5aa6ec53c22f9c0225 100644 >--- a/Source/WebCore/platform/graphics/FontCache.h >+++ b/Source/WebCore/platform/graphics/FontCache.h >@@ -40,7 +40,7 @@ > #include <wtf/text/AtomicStringHash.h> > #include <wtf/text/WTFString.h> > >-#if PLATFORM(IOS) >+#if PLATFORM(COCOA) > #include <CoreText/CTFont.h> > #endif > >@@ -214,6 +214,10 @@ private: > friend class Font; > }; > >+#if PLATFORM(COCOA) >+RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef, const FontFeatureSettings&); >+#endif >+ > #if !PLATFORM(MAC) > inline void FontCache::platformPurgeInactiveFontData() > { >diff --git a/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp b/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..5b6ca598cc42bc8a2c50c2031b333836525249bc >--- /dev/null >+++ b/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp >@@ -0,0 +1,67 @@ >+/* >+ * Copyright (C) 2015 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#import "config.h" >+#import "FontCache.h" >+ >+namespace WebCore { >+ >+static inline void appendTrueTypeFeature(CFMutableArrayRef features, const FontFeature& feature) >+{ >+ // FIXME: We should map OpenType feature strings to the TrueType feature type identifiers listed in <CoreText/SFNTLayoutTypes.h> >+ UNUSED_PARAM(features); >+ UNUSED_PARAM(feature); >+} >+ >+static inline void appendOpenTypeFeature(CFMutableArrayRef features, const FontFeature& feature) >+{ >+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) >+ RetainPtr<CFStringRef> featureKey = feature.tag().string().createCFString(); >+ int rawFeatureValue = feature.value(); >+ RetainPtr<CFNumberRef> featureValue = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &rawFeatureValue)); >+ CFStringRef featureDictionaryKeys[] = {kCTFontOpenTypeFeatureTag, kCTFontOpenTypeFeatureValue}; >+ CFTypeRef featureDictionaryValues[] = {featureKey.get(), featureValue.get()}; >+ RetainPtr<CFDictionaryRef> featureDictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)featureDictionaryKeys, featureDictionaryValues, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); >+ CFArrayAppendValue(features, featureDictionary.get()); >+#else >+ UNUSED_PARAM(features); >+ UNUSED_PARAM(feature); >+#endif >+} >+ >+RetainPtr<CTFontRef> applyFontFeatureSettings(CTFontRef originalFont, const FontFeatureSettings& features) >+{ >+ RetainPtr<CFMutableArrayRef> featureArray = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, features.size(), &kCFTypeArrayCallBacks)); >+ for (size_t i = 0; i < features.size(); ++i) { >+ appendTrueTypeFeature(featureArray.get(), features[i]); >+ appendOpenTypeFeature(featureArray.get(), features[i]); >+ } >+ CFArrayRef featureArrayPtr = featureArray.get(); >+ RetainPtr<CFDictionaryRef> dictionary = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, (const void**)&kCTFontFeatureSettingsAttribute, (const void**)&featureArrayPtr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); >+ RetainPtr<CTFontDescriptorRef> descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(dictionary.get())); >+ return adoptCF(CTFontCreateCopyWithAttributes(originalFont, CTFontGetSize(originalFont), nullptr, descriptor.get())); >+} >+ >+} >diff --git a/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm b/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm >index d7d9c5250371d5305df2dc1ec16ec6ca842da75e..9d96dd3371607bb366f74afad9e91f5a4e060d26 100644 >--- a/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm >+++ b/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm >@@ -85,6 +85,9 @@ PassRefPtr<Font> FontCache::getSystemFontFallbackForCharacters(const FontDescrip > if (!substituteFont) > return nullptr; > >+ if (substituteFont && description.featureSettings() && description.featureSettings()->size()) >+ substituteFont = applyFontFeatureSettings(substituteFont.get(), *description.featureSettings()); >+ > CTFontSymbolicTraits originalTraits = CTFontGetSymbolicTraits(ctFont); > CTFontSymbolicTraits actualTraits = 0; > if (isFontWeightBold(description.weight()) || description.italic()) >@@ -692,6 +695,9 @@ std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe > if (!ctFont) > return nullptr; > >+ if (ctFont && fontDescription.featureSettings() && fontDescription.featureSettings()->size()) >+ ctFont = applyFontFeatureSettings(ctFont.get(), *fontDescription.featureSettings()); >+ > CTFontSymbolicTraits actualTraits = 0; > if (isFontWeightBold(fontDescription.weight()) || fontDescription.italic()) > actualTraits = CTFontGetSymbolicTraits(ctFont.get()); >diff --git a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm b/Source/WebCore/platform/graphics/mac/FontCacheMac.mm >index aebbe984c4ad6007dcf10629e9d1d121d7165f04..3b2a8e708f450f68d2e48dd253e6c63fa55f6f7f 100644 >--- a/Source/WebCore/platform/graphics/mac/FontCacheMac.mm >+++ b/Source/WebCore/platform/graphics/mac/FontCacheMac.mm >@@ -264,7 +264,7 @@ static Optional<NSFont*> fontWithFamilySpecialCase(const AtomicString& family, F > // 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. >-static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, float size) >+static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, const FontFeatureSettings* featureSettings, float size) > { > if (const auto& specialCase = fontWithFamilySpecialCase(family, weight, desiredTraits, size)) > return specialCase.value(); >@@ -286,12 +286,19 @@ static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desire > requestedTraits |= kCTFontBoldTrait; > > NSString *desiredFamily = family; >- font = CFBridgingRelease(CTFontCreateForCSS((CFStringRef)desiredFamily, toCoreTextFontWeight(weight), requestedTraits, size)); >+ RetainPtr<CTFontRef> foundFont = adoptCF(CTFontCreateForCSS((CFStringRef)desiredFamily, toCoreTextFontWeight(weight), requestedTraits, size)); >+ if (!foundFont) >+ return nil; >+ if (featureSettings && featureSettings->size()) >+ foundFont = applyFontFeatureSettings(foundFont.get(), *featureSettings); >+ font = CFBridgingRelease(CFRetain(foundFont.get())); > availableFamily = [font familyName]; > chosenWeight = [fontManager weightOfFont:font]; > > #else > >+ UNUSED_PARAM(featureSettings); >+ > NSFontTraitMask desiredTraitsForNameMatch = desiredTraits | (weight >= FontWeight600 ? NSBoldFontMask : 0); > if (hasDesiredFamilyToAvailableFamilyMapping(family, desiredTraitsForNameMatch, availableFamily)) { > if (!availableFamily) { >@@ -506,6 +513,8 @@ RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& descr > const FontPlatformData& platformData = originalFontData->platformData(); > NSFont *nsFont = platformData.nsFont(); > RetainPtr<CTFontRef> result = lookupCTFont(platformData.font(), platformData.size(), characters, length); >+ if (result && description.featureSettings() && description.featureSettings()->size()) >+ result = applyFontFeatureSettings(result.get(), *description.featureSettings()); > if (!result) > return nullptr; > >@@ -664,7 +673,7 @@ std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe > NSFontTraitMask traits = fontDescription.italic() ? NSFontItalicTrait : 0; > float size = fontDescription.computedPixelSize(); > >- NSFont *nsFont = fontWithFamily(family, traits, fontDescription.weight(), size); >+ NSFont *nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), size); > if (!nsFont) { > if (!shouldAutoActivateFontIfNeeded(family)) > return nullptr; >@@ -673,7 +682,7 @@ std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe > // Ignore the result because we want to use our own algorithm to actually find the font. > [NSFont fontWithName:family size:size]; > >- nsFont = fontWithFamily(family, traits, fontDescription.weight(), size); >+ nsFont = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), size); > if (!nsFont) > return nullptr; > } >diff --git a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp >index 6d26073b413250c1274cc022eca0bd136523498f..c8fd86e54e2709aff90b796822d7c6114b7269d3 100644 >--- a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp >+++ b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp >@@ -21,6 +21,7 @@ > #include "config.h" > #include "FontCustomPlatformData.h" > >+#include "FontCache.h" > #include "FontPlatformData.h" > #include "SharedBuffer.h" > #include <CoreGraphics/CoreGraphics.h> >@@ -32,10 +33,17 @@ FontCustomPlatformData::~FontCustomPlatformData() > { > } > >-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode) >+FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic) > { >+ int size = fontDescription.computedPixelSize(); >+ FontOrientation orientation = fontDescription.orientation(); >+ FontWidthVariant widthVariant = fontDescription.widthVariant(); > #if CORETEXT_WEB_FONTS >- return FontPlatformData(adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr)).get(), size, bold, italic, orientation, widthVariant); >+ RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr)); >+ if (font && fontDescription.featureSettings() && fontDescription.featureSettings()->size()) >+ font = applyFontFeatureSettings(font.get(), *fontDescription.featureSettings()); >+ return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant); >+ > #else > return FontPlatformData(m_cgFont.get(), size, bold, italic, orientation, widthVariant); > #endif >diff --git a/Source/WebCore/rendering/RenderThemeIOS.mm b/Source/WebCore/rendering/RenderThemeIOS.mm >index 327ba5ae269ebd6c720ceb02e35657a989e360b7..755cf8775fba0db08b0519e20be054d9aa19d864 100644 >--- a/Source/WebCore/rendering/RenderThemeIOS.mm >+++ b/Source/WebCore/rendering/RenderThemeIOS.mm >@@ -1261,6 +1261,8 @@ void RenderThemeIOS::updateCachedSystemFontDescription(CSSValueID valueID, FontD > > ASSERT(fontDescriptor); > RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr)); >+ if (font && fontDescription.featureSettings() && fontDescription.featureSettings()->size()) >+ font = applyFontFeatureSettings(font.get(), *fontDescription.featureSettings()); > fontDescription.setIsAbsoluteSize(true); > fontDescription.setOneFamily(textStyle); > fontDescription.setSpecifiedSize(CTFontGetSize(font.get()));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 147722
:
258349
|
258425
|
258427
|
258428
|
258431
|
258432
|
258433
|
258435
|
258444
|
258456
|
258472
|
258477
|
258507
|
258511
|
258512