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-20150806223444.patch (text/plain), 32.61 KB, created by
Myles C. Maxfield
on 2015-08-06 22:34:54 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Myles C. Maxfield
Created:
2015-08-06 22:34:54 PDT
Size:
32.61 KB
patch
obsolete
>Subversion Revision: 188116 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 5bef453bef36c3fee64c94203c92de943498e38a..f5f0182bbab59f3b92edcbae9faecdbf09bb3d81 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,59 @@ >+2015-08-06 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 other fonts. Font feature >+ information is contained within fontDescription, and our caches are >+ 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, 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 forthcoming. >+ >+ * WebCore.xcodeproj/project.pbxproj: Add FontCacheCoreText.cpp. >+ * css/CSSFontFaceSource.cpp: >+ (WebCore::CSSFontFaceSource::font): Pass FontDescription data down >+ to the webfont creation routine. >+ * loader/cache/CachedFont.cpp: >+ (WebCore::CachedFont::createFont): Ditto. >+ (WebCore::CachedFont::platformDataFromCustomData): Ditto. >+ * loader/cache/CachedFont.h: >+ * loader/cache/CachedSVGFont.cpp: >+ (WebCore::CachedSVGFont::platformDataFromCustomData): Ditto. >+ * loader/cache/CachedSVGFont.h: >+ * platform/graphics/FontCache.h: >+ * platform/graphics/cocoa/FontCacheCoreText.cpp: Added. >+ (WebCore::appendOpenTypeFeature): What the name says. >+ (WebCore::appendTrueTypeFeature): 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. >+ * platform/graphics/cairo/FontCustomPlatformData.h: >+ * platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp: >+ (WebCore::FontCustomPlatformData::fontPlatformData): Pass >+ FontDescription data down to the webfont creation routine. >+ * platform/graphics/freetype/FontPlatformData.h: >+ * platform/graphics/freetype/FontPlatformDataFreeType.cpp: Ditto. >+ * platform/graphics/mac/FontCustomPlatformData.h: >+ * rendering/RenderThemeIOS.mm: >+ (WebCore::RenderThemeIOS::updateCachedSystemFontDescription): Ditto. >+ > 2015-08-06 Alex Christensen <achristensen@webkit.org> > > Fix GTK clean build after r187997 >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/css/CSSFontFaceSource.cpp b/Source/WebCore/css/CSSFontFaceSource.cpp >index 75bfd81d99debacc575dcf676b227bf35b566dac..0bca2a7f061f5e59fdf4e30dbbae4bf2be9a8958 100644 >--- a/Source/WebCore/css/CSSFontFaceSource.cpp >+++ b/Source/WebCore/css/CSSFontFaceSource.cpp >@@ -151,7 +151,7 @@ RefPtr<Font> CSSFontFaceSource::font(const FontDescription& fontDescription, boo > if (!m_generatedOTFBuffer) > return nullptr; > std::unique_ptr<FontCustomPlatformData> customPlatformData = createFontCustomPlatformData(*m_generatedOTFBuffer); >- font = Font::create(customPlatformData->fontPlatformData(static_cast<int>(fontDescription.computedPixelSize()), syntheticBold, syntheticItalic, fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false); >+ font = Font::create(customPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic), true, false); > #else > font = Font::create(std::make_unique<SVGFontData>(m_svgFontFaceElement.get()), fontDescription.computedPixelSize(), syntheticBold, syntheticItalic); > #endif >diff --git a/Source/WebCore/loader/cache/CachedFont.cpp b/Source/WebCore/loader/cache/CachedFont.cpp >index 8f3e8883f75e659bd1c5f77b9377a6a76d541c97..1604e39d76d7a581b4b548d6453f7888b3318a11 100644 >--- a/Source/WebCore/loader/cache/CachedFont.cpp >+++ b/Source/WebCore/loader/cache/CachedFont.cpp >@@ -123,14 +123,13 @@ bool CachedFont::ensureCustomFontData(SharedBuffer* data) > > RefPtr<Font> CachedFont::createFont(const FontDescription& fontDescription, const AtomicString&, bool syntheticBold, bool syntheticItalic, bool) > { >- return Font::create(platformDataFromCustomData(fontDescription.computedPixelSize(), syntheticBold, syntheticItalic, >- fontDescription.orientation(), fontDescription.widthVariant(), fontDescription.renderingMode()), true, false); >+ return Font::create(platformDataFromCustomData(fontDescription, syntheticBold, syntheticItalic), true, false); > } > >-FontPlatformData CachedFont::platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode renderingMode) >+FontPlatformData CachedFont::platformDataFromCustomData(const FontDescription& fontDescription, bool bold, bool italic) > { > ASSERT(m_fontCustomPlatformData); >- return m_fontCustomPlatformData->fontPlatformData(static_cast<int>(size), bold, italic, orientation, widthVariant, renderingMode); >+ return m_fontCustomPlatformData->fontPlatformData(fontDescription, bold, italic); > } > > void CachedFont::allClientsRemoved() >diff --git a/Source/WebCore/loader/cache/CachedFont.h b/Source/WebCore/loader/cache/CachedFont.h >index c50ae44a9e8ed125697068c71c749c75e56f455e..8f28d57aa6384b6d80d822f3ec728a9073c37447 100644 >--- a/Source/WebCore/loader/cache/CachedFont.h >+++ b/Source/WebCore/loader/cache/CachedFont.h >@@ -53,7 +53,7 @@ public: > virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG); > > protected: >- FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode); >+ FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic); > > bool ensureCustomFontData(SharedBuffer* data); > >diff --git a/Source/WebCore/loader/cache/CachedSVGFont.cpp b/Source/WebCore/loader/cache/CachedSVGFont.cpp >index 51e780847d5d55ed236b969772b3a5bb56789e67..4d459facbb061c4bd4656503cfd5b35dfe84fb99 100644 >--- a/Source/WebCore/loader/cache/CachedSVGFont.cpp >+++ b/Source/WebCore/loader/cache/CachedSVGFont.cpp >@@ -66,11 +66,11 @@ RefPtr<Font> CachedSVGFont::createFont(const FontDescription& fontDescription, c > return nullptr; > } > >-FontPlatformData CachedSVGFont::platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant widthVariant, FontRenderingMode renderingMode) >+FontPlatformData CachedSVGFont::platformDataFromCustomData(const FontDescription& fontDescription, bool bold, bool italic) > { > if (m_externalSVGDocument) >- return FontPlatformData(size, bold, italic); >- return CachedFont::platformDataFromCustomData(size, bold, italic, orientation, widthVariant, renderingMode); >+ return FontPlatformData(fontDescription.computedPixelSize(), bold, italic); >+ return CachedFont::platformDataFromCustomData(fontDescription, bold, italic); > } > > bool CachedSVGFont::ensureCustomFontData(bool externalSVG, const AtomicString& remoteURI) >diff --git a/Source/WebCore/loader/cache/CachedSVGFont.h b/Source/WebCore/loader/cache/CachedSVGFont.h >index 0a4b651d0fc4098022cadad8a1fe23f30610f82b..5e373b416db00b833ea8b545201cc40b56522ce2 100644 >--- a/Source/WebCore/loader/cache/CachedSVGFont.h >+++ b/Source/WebCore/loader/cache/CachedSVGFont.h >@@ -43,7 +43,7 @@ public: > virtual RefPtr<Font> createFont(const FontDescription&, const AtomicString& remoteURI, bool syntheticBold, bool syntheticItalic, bool externalSVG) override; > > private: >- FontPlatformData platformDataFromCustomData(float size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode); >+ FontPlatformData platformDataFromCustomData(const FontDescription&, bool bold, bool italic); > > SVGFontElement* getSVGFontById(const String&) const; > >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/cairo/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h >index 18fe80df36c6a0bb5340b645b2505893dd4fdebc..c95ef9b5b908258af3ab994d33f241925db3211f 100644 >--- a/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h >+++ b/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h >@@ -33,6 +33,7 @@ typedef struct _cairo_font_face cairo_font_face_t; > > namespace WebCore { > >+class FontDescription; > class FontPlatformData; > class SharedBuffer; > >@@ -41,7 +42,7 @@ struct FontCustomPlatformData { > public: > FontCustomPlatformData(FT_Face, SharedBuffer&); > ~FontCustomPlatformData(); >- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode); >+ FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic); > static bool supportsFormat(const String&); > > private: >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/freetype/FontCustomPlatformDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp >index 30af28c69df4a68034103834ed700f45c6f096f4..46d9471d618f73e1a6c4b365110a63574d3db81c 100644 >--- a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp >+++ b/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp >@@ -68,9 +68,9 @@ FontCustomPlatformData::~FontCustomPlatformData() > cairo_font_face_destroy(m_fontFace); > } > >-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant, FontRenderingMode) >+FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& description, bool bold, bool italic) > { >- return FontPlatformData(m_fontFace, size, bold, italic, orientation); >+ return FontPlatformData(m_fontFace, description, bold, italic); > } > > std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer) >diff --git a/Source/WebCore/platform/graphics/freetype/FontPlatformData.h b/Source/WebCore/platform/graphics/freetype/FontPlatformData.h >index 393d594aebb07d312dd129b6d226b8ad33961b06..128ef57ad841c9997c7f346b74e469e4330cd4ff 100644 >--- a/Source/WebCore/platform/graphics/freetype/FontPlatformData.h >+++ b/Source/WebCore/platform/graphics/freetype/FontPlatformData.h >@@ -63,7 +63,7 @@ public: > { } > > FontPlatformData(FcPattern*, const FontDescription&); >- FontPlatformData(cairo_font_face_t*, float size, bool bold, bool italic, FontOrientation); >+ FontPlatformData(cairo_font_face_t*, const FontDescription&, bool bold, bool italic); > FontPlatformData(float size, bool bold, bool italic); > FontPlatformData(const FontPlatformData&); > FontPlatformData(const FontPlatformData&, float size); >diff --git a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp >index f7226b588d932e8b90b34a2f327dc20515bf4a1b..bd3bc44a167404037d406a3ebdbaf6cddd5af68c 100644 >--- a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp >+++ b/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp >@@ -187,14 +187,14 @@ FontPlatformData::FontPlatformData(float size, bool bold, bool italic) > // We cannot create a scaled font here. > } > >-FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool italic, FontOrientation orientation) >+FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, const FontDescription& description, bool bold, bool italic) > : m_fallbacks(nullptr) >- , m_size(size) >+ , m_size(description.computedPixelSize()) > , m_syntheticBold(bold) > , m_syntheticOblique(italic) > , m_fixedWidth(false) > , m_scaledFont(nullptr) >- , m_orientation(orientation) >+ , m_orientation(description.orientation()) > { > buildScaledFont(fontFace); > >diff --git a/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp >index fc43c61b2e9a20ab8451d6d527a51409ea19b8ec..55e3488f05cb7486db3e301c1babb923a7ac9476 100644 >--- a/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp >+++ b/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp >@@ -103,11 +103,12 @@ void Font::platformCharWidthInit() > PassRefPtr<Font> Font::platformCreateScaledFont(const FontDescription& fontDescription, float scaleFactor) const > { > ASSERT(m_platformData.scaledFont()); >+ FontDescription scaledFontDescription = fontDescription; >+ scaledFontDescription.setComputedSize(scaleFactor * fontDescription.computedSize()); > return Font::create(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()), >- scaleFactor * fontDescription.computedSize(), >+ scaledFontDescription, > m_platformData.syntheticBold(), >- m_platformData.syntheticOblique(), >- fontDescription.orientation()), >+ m_platformData.syntheticOblique()), > isCustomFont(), false); > } > >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/platform/graphics/mac/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h >index 03f7a870ed5411ccf7815f1978ed2971635dd06e..0babf799a95ebd238a8256ca68f9c02d303bcfb6 100644 >--- a/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h >+++ b/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h >@@ -21,6 +21,7 @@ > #ifndef FontCustomPlatformData_h > #define FontCustomPlatformData_h > >+#include "FontDescription.h" > #include "TextFlags.h" > #include <CoreFoundation/CFBase.h> > #include <wtf/Forward.h> >@@ -50,7 +51,7 @@ public: > > ~FontCustomPlatformData(); > >- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode); >+ FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic); > > static bool supportsFormat(const String&); > >diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp >index 098e09b338dc8a6525d5bcde8065bc37a675a897..55a7be57c98285e973cfb3148260c6e5e74c4e47 100644 >--- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp >+++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp >@@ -40,8 +40,11 @@ FontCustomPlatformData::~FontCustomPlatformData() > RemoveFontMemResourceEx(m_fontReference); > } > >-FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, FontWidthVariant, FontRenderingMode renderingMode) >+FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription& fontDescription, bool bold, bool italic) > { >+ int size = fontDescription.computedPixelSize(); >+ FontRenderingMode renderingMode = fontDescription.renderingMode(); >+ > ASSERT(m_fontReference); > > LOGFONT& logFont = *static_cast<LOGFONT*>(malloc(sizeof(LOGFONT))); >diff --git a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h >index a7d6621560d7c598f0cb251e0e1e0f955e9f13fe..6b919da0c49c718541c263c5a077b3fefceafc94 100644 >--- a/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h >+++ b/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h >@@ -31,6 +31,7 @@ typedef struct CGFont* CGFontRef; > > namespace WebCore { > >+class FontDescription; > class FontPlatformData; > class SharedBuffer; > >@@ -45,8 +46,7 @@ public: > > ~FontCustomPlatformData(); > >- FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, >- FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode); >+ FontPlatformData fontPlatformData(const FontDescription&, bool bold, bool italic); > > static bool supportsFormat(const String&); > >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