Changeset 266936 in webkit
- Timestamp:
- Sep 11, 2020 1:27:38 PM (4 years ago)
- Location:
- trunk/Source
- Files:
-
- 3 added
- 17 edited
- 2 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r266929 r266936 1 2020-09-11 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Migrate CoreText-specific code from ***Cocoa.mm to ***CoreText.cpp 4 https://bugs.webkit.org/show_bug.cgi?id=216400 5 6 Reviewed by Tim Horton. 7 8 * wtf/PlatformUse.h: 9 1 10 2020-09-11 Kate Cheney <katherine_cheney@apple.com> 2 11 -
trunk/Source/WTF/wtf/PlatformUse.h
r266672 r266936 56 56 57 57 #if PLATFORM(COCOA) 58 #define USE_CORE_TEXT 1 59 #endif 60 61 #if PLATFORM(COCOA) 58 62 #define USE_CA 1 59 63 #endif -
trunk/Source/WebCore/ChangeLog
r266934 r266936 1 2020-09-11 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Migrate CoreText-specific code from ***Cocoa.mm to ***CoreText.cpp 4 https://bugs.webkit.org/show_bug.cgi?id=216400 5 6 Reviewed by Tim Horton. 7 8 This is in preparation for sharing the CoreText code with the Apple Windows port. 9 10 This patch doesn't actually cause Windows to use this code yet. That will happen 11 in a series of subsequent patches. This patch is just the first stage. 12 13 There isn't any actual behavior change here - it's just moving code around between 14 files. 15 16 This patch also adds a new USE() flag: USE(CORE_TEXT). It migrates CoreText-specific 17 code from #if PLATFORM(COCOA) to #if USE(CORE_TEXT). 18 19 No new tests because there is no behavior change. 20 21 * PlatformMac.cmake: 22 * SourcesCocoa.txt: 23 * WebCore.xcodeproj/project.pbxproj: 24 * platform/graphics/Font.cpp: 25 * platform/graphics/Font.h: 26 * platform/graphics/FontCascade.cpp: 27 * platform/graphics/FontCascade.h: 28 * platform/graphics/FontPlatformData.cpp: 29 * platform/graphics/FontPlatformData.h: 30 * platform/graphics/cocoa/FontCascadeCocoa.mm: 31 (WebCore::showLetterpressedGlyphsWithAdvances): 32 (WebCore::FontCascade::isSubpixelAntialiasingAvailable): Deleted. 33 (WebCore::fillVectorWithHorizontalGlyphPositions): Deleted. 34 (WebCore::shouldUseLetterpressEffect): Deleted. 35 (WebCore::showGlyphsWithAdvances): Deleted. 36 (WebCore::setCGFontRenderingMode): Deleted. 37 (WebCore::FontCascade::drawGlyphs): Deleted. 38 (WebCore::FontCascade::primaryFontIsSystemFont const): Deleted. 39 (WebCore::FontCascade::fontForCombiningCharacterSequence const): Deleted. 40 * platform/graphics/cocoa/FontCocoa.cpp: Added. 41 (WebCore::Font::platformDestroy): 42 * platform/graphics/cocoa/FontPlatformDataCocoa.mm: 43 (WebCore::FontPlatformData::hash const): 44 (WebCore::isSystemFont): Deleted. 45 (): Deleted. 46 (WebCore::FontPlatformData::FontPlatformData): Deleted. 47 (WebCore::FontPlatformData::registeredFont const): Deleted. 48 (WebCore::mapFontWidthVariantToCTFeatureSelector): Deleted. 49 (WebCore::cascadeToLastResortAttributesDictionary): Deleted. 50 (WebCore::cascadeToLastResortAndVariationsFontDescriptor): Deleted. 51 (WebCore::FontPlatformData::ctFont const): Deleted. 52 (WebCore::FontPlatformData::objectForEqualityCheck): Deleted. 53 (WebCore::FontPlatformData::objectForEqualityCheck const): Deleted. 54 (WebCore::FontPlatformData::openTypeTable const): Deleted. 55 (WebCore::FontPlatformData::description const): Deleted. 56 (WebCore::FontPlatformData::familyName const): Deleted. 57 * platform/graphics/cocoa/SourceBufferParserWebM.cpp: 58 * platform/graphics/ct/FontCascadeCoreText.cpp: Copied from Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm. 59 (WebCore::FontCascade::isSubpixelAntialiasingAvailable): 60 (WebCore::fillVectorWithHorizontalGlyphPositions): 61 (WebCore::shouldUseLetterpressEffect): 62 (WebCore::showGlyphsWithAdvances): 63 (WebCore::setCGFontRenderingMode): 64 (WebCore::FontCascade::drawGlyphs): 65 (WebCore::FontCascade::primaryFontIsSystemFont const): 66 (WebCore::FontCascade::fontForCombiningCharacterSequence const): 67 * platform/graphics/ct/FontCoreText.cpp: Renamed from Source/WebCore/platform/graphics/cocoa/FontCocoa.mm. 68 (WebCore::Font::platformInit): 69 (WebCore::Font::platformCharWidthInit): 70 (WebCore::Font::platformCreateScaledFont const): 71 (WebCore::Font::applyTransforms const): 72 * platform/graphics/ct/FontPlatformDataCoreText.cpp: Copied from Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm. 73 (WebCore::FontPlatformData::FontPlatformData): 74 (WebCore::isSystemFont): 75 (WebCore::FontPlatformData::registeredFont const): 76 (WebCore::mapFontWidthVariantToCTFeatureSelector): 77 (WebCore::cascadeToLastResortAttributesDictionary): 78 (WebCore::cascadeToLastResortAndVariationsFontDescriptor): 79 (WebCore::FontPlatformData::ctFont const): 80 (WebCore::FontPlatformData::objectForEqualityCheck): 81 (WebCore::FontPlatformData::objectForEqualityCheck const): 82 (WebCore::FontPlatformData::openTypeTable const): 83 (WebCore::FontPlatformData::description const): 84 (WebCore::FontPlatformData::familyName const): 85 * platform/graphics/ct/GlyphPageCoreText.cpp: Renamed from Source/WebCore/platform/graphics/mac/GlyphPageMac.cpp. 86 * platform/graphics/win/FontCascadeCGWin.cpp: Added. 87 (WebCore::FontCascade::setFontSmoothingLevel): 88 (WebCore::setCGFontSmoothingStyle): 89 (WebCore::FontCascade::setFontSmoothingStyle): 90 (WebCore::FontCascade::setFontSmoothingContrast): 91 (WebCore::clearTypeContrast): 92 (WebCore::FontCascade::systemFontSmoothingChanged): 93 (WebCore::FontCascade::setCGContextFontRenderingStyle): 94 (WebCore::renderingStyleForFont): 95 (WebCore::FontCascade::getPlatformGlyphAdvances): 96 1 97 2020-09-11 Devin Rousso <drousso@apple.com> 2 98 -
trunk/Source/WebCore/PAL/ChangeLog
r266932 r266936 1 2020-09-11 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Migrate CoreText-specific code from ***Cocoa.mm to ***CoreText.cpp 4 https://bugs.webkit.org/show_bug.cgi?id=216400 5 6 Reviewed by Tim Horton. 7 8 * pal/spi/win/CoreTextSPIWin.h: 9 1 10 2020-09-11 Ben Nham <nham@apple.com> 2 11 -
trunk/Source/WebCore/PAL/pal/spi/win/CoreTextSPIWin.h
r237845 r266936 43 43 CT_EXPORT const CFStringRef kCTStrokeWidthAttributeName; 44 44 CT_EXPORT const CFStringRef kCTStrokeColorAttributeName; 45 CT_EXPORT const CFStringRef kCTFontOpenTypeFeatureTag; 46 CT_EXPORT const CFStringRef kCTFontFeatureTypeIdentifierKey; 47 CT_EXPORT const CFStringRef kCTFontOpenTypeFeatureValue; 48 CT_EXPORT const CFStringRef kCTFontFeatureSelectorIdentifierKey; 49 CT_EXPORT const CFStringRef kCTFontFeatureTypeSelectorsKey; 50 CT_EXPORT const CFStringRef kCTFontFeatureSelectorDefaultKey; 51 CT_EXPORT const CFStringRef kCTFontFeatureSettingsAttribute; 52 CT_EXPORT const CFStringRef kCTFontFixedAdvanceAttribute; 53 CT_EXPORT const CFStringRef kCTFontVariationAttribute; 54 CT_EXPORT const CFStringRef kCTFontURLAttribute; 55 CT_EXPORT const CFStringRef kCTFontReferenceURLAttribute; 45 56 46 // Th is enum is defined in CTFont.h. To avoid redefinition, only define ithere if CTFont.h has not been included.57 // These enums are defined in CTFont.h. To avoid redefinition, only define them here if CTFont.h has not been included. 47 58 #ifndef __CTFONT__ 59 typedef CF_OPTIONS(uint32_t, CTFontSymbolicTraits) { 60 kCTFontTraitItalic = (1 << 0), 61 kCTFontTraitBold = (1 << 1), 62 kCTFontTraitMonoSpace = (1 << 10), 63 kCTFontTraitColorGlyphs = (1 << 13), 64 65 kCTFontItalicTrait = kCTFontTraitItalic, 66 kCTFontBoldTrait = kCTFontTraitBold, 67 kCTFontMonoSpaceTrait = kCTFontTraitMonoSpace, 68 kCTFontColorGlyphsTrait = kCTFontTraitColorGlyphs, 69 }; 70 48 71 typedef CF_OPTIONS(uint32_t, CTFontTableOptions) { 49 72 kCTFontTableOptionNoOptions = 0, 50 73 kCTFontTableOptionExcludeSynthetic = (1 << 0) 51 74 }; 75 76 enum { 77 kCTFontTableMATH = 'MATH', 78 kCTFontTableOS2 = 'OS/2', 79 kCTFontTableVORG = 'VORG', 80 kCTFontTableHead = 'head', 81 kCTFontTableVhea = 'vhea', 82 }; 83 84 typedef CF_OPTIONS(uint32_t, CTFontTransformOptions) { 85 kCTFontTransformApplyShaping = (1 << 0), 86 kCTFontTransformApplyPositioning = (1 << 1) 87 }; 88 89 enum { 90 kLowerCaseType = 37, 91 kUpperCaseType = 38, 92 }; 93 94 enum { 95 kDefaultLowerCaseSelector = 0, 96 kLowerCaseSmallCapsSelector = 1, 97 kLowerCasePetiteCapsSelector = 2 98 }; 99 100 enum { 101 kDefaultUpperCaseSelector = 0, 102 kUpperCaseSmallCapsSelector = 1, 103 kUpperCasePetiteCapsSelector = 2 104 }; 105 106 enum { 107 kProportionalTextSelector = 0, 108 kHalfWidthTextSelector = 2, 109 kThirdWidthTextSelector = 3, 110 kQuarterWidthTextSelector = 4, 111 }; 112 113 typedef CF_ENUM(uint32_t, CTFontOrientation) 114 { 115 kCTFontOrientationDefault = 0, 116 kCTFontOrientationHorizontal = 1, 117 kCTFontOrientationVertical = 2, 118 }; 52 119 #endif 53 120 121 unsigned CTFontGetUnitsPerEm(CTFontRef); 122 CGFloat CTFontGetCapHeight(CTFontRef); 123 CGFloat CTFontGetLeading(CTFontRef); 124 CGFloat CTFontGetAscent(CTFontRef); 125 CGFloat CTFontGetDescent(CTFontRef); 126 CGFloat CTFontGetXHeight(CTFontRef); 127 CGFloat CTFontGetUnderlinePosition(CTFontRef); 128 CGFloat CTFontGetUnderlineThickness(CTFontRef); 129 CGFloat CTFontGetSize(CTFontRef); 130 CTFontSymbolicTraits CTFontGetSymbolicTraits(CTFontRef); 131 CFCharacterSetRef CTFontCopyCharacterSet(CTFontRef); 132 CFStringRef CTFontCopyFamilyName(CTFontRef); 133 CFStringRef CTFontCopyFullName(CTFontRef); 134 CTFontRef CTFontCreateCopyWithAttributes(CTFontRef, CGFloat size, const CGAffineTransform* matrix, CTFontDescriptorRef attributes); 54 135 CTFontRef CTFontCreateWithName(CFStringRef, CGFloat size, const CGAffineTransform*); 55 136 CTFontRef CTFontCreateWithGraphicsFont(CGFontRef, CGFloat size, const CGAffineTransform*, CTFontDescriptorRef attributes); 137 CTFontRef CTFontCreateWithFontDescriptor(CTFontDescriptorRef, CGFloat size, const CGAffineTransform*); 56 138 CTLineRef CTLineCreateWithAttributedString(CFAttributedStringRef); 57 139 void CTLineDraw(CTLineRef, CGContextRef); … … 59 141 CFArrayRef CTFontCopyAvailableTables(CTFontRef, CTFontTableOptions); 60 142 CGPathRef CTFontCreatePathForGlyph(CTFontRef, CGGlyph, const CGAffineTransform*); 143 void CTFontGetVerticalTranslationsForGlyphs(CTFontRef, const CGGlyph[], CGSize translations[], CFIndex count); 144 void CTFontDrawGlyphs(CTFontRef, const CGGlyph[], const CGPoint[], size_t count, CGContextRef); 145 CGAffineTransform CTFontGetMatrix(CTFontRef); 146 CFArrayRef CTFontCopyFeatures(CTFontRef); 147 CFTypeRef CTFontCopyAttribute(CTFontRef, CFStringRef); 148 CTFontDescriptorRef CTFontCopyFontDescriptor(CTFontRef); 149 bool CTFontTransformGlyphs(CTFontRef, CGGlyph[], CGSize advances[], CFIndex count, CTFontTransformOptions); 150 CGRect CTFontGetBoundingRectsForGlyphs(CTFontRef, CTFontOrientation, const CGGlyph[], CGRect boundingRects[], CFIndex count); 151 double CTFontGetAdvancesForGlyphs(CTFontRef, CTFontOrientation, const CGGlyph[], CGSize advances[], CFIndex count); 152 bool CTFontGetGlyphsForCharacters(CTFontRef, const UniChar[], CGGlyph[], CFIndex count); 153 bool CTFontGetGlyphsForCharacterRange(CTFontRef, CGGlyph[], CFRange); 154 CFDataRef CTFontCopyTable(CTFontRef, CTFontTableTag, CTFontTableOptions); 155 bool CTFontGetVerticalGlyphsForCharacters(CTFontRef, const UniChar[], CGGlyph[], CFIndex count); 156 157 CTFontDescriptorRef CTFontDescriptorCreateWithAttributes(CFDictionaryRef); 158 bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef); 159 CTFontDescriptorRef CTFontDescriptorCreateWithNameAndSize(CFStringRef, CGFloat); 61 160 62 161 WTF_EXTERN_C_END -
trunk/Source/WebCore/PlatformMac.cmake
r266663 r266936 307 307 platform/graphics/cocoa/FontCacheCoreText.cpp 308 308 platform/graphics/cocoa/FontCascadeCocoa.mm 309 platform/graphics/cocoa/FontCocoa. mm309 platform/graphics/cocoa/FontCocoa.cpp 310 310 platform/graphics/cocoa/FontDescriptionCocoa.cpp 311 311 platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp … … 322 322 platform/graphics/cocoa/WebGPULayer.mm 323 323 324 platform/graphics/ct/FontCascadeCoreText.cpp 325 platform/graphics/ct/FontCoreText.cpp 326 platform/graphics/ct/FontPlatformDataCoreText.cpp 327 platform/graphics/ct/GlyphPageCoreText.cpp 328 324 329 platform/graphics/cv/ImageRotationSessionVT.mm 325 330 platform/graphics/cv/PixelBufferConformerCV.cpp … … 336 341 platform/graphics/mac/FloatSizeMac.mm 337 342 platform/graphics/mac/FontCustomPlatformData.cpp 338 platform/graphics/mac/GlyphPageMac.cpp339 343 platform/graphics/mac/IconMac.mm 340 344 platform/graphics/mac/ImageMac.mm -
trunk/Source/WebCore/SourcesCocoa.txt
r266673 r266936 348 348 platform/graphics/cocoa/FontCacheCoreText.cpp 349 349 platform/graphics/cocoa/FontCascadeCocoa.mm 350 platform/graphics/cocoa/FontCocoa. mm350 platform/graphics/cocoa/FontCocoa.cpp 351 351 platform/graphics/cocoa/FontDescriptionCocoa.cpp 352 352 platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp … … 370 370 platform/graphics/cocoa/WebGPULayer.mm 371 371 platform/graphics/cocoa/VideoTrackPrivateWebM.cpp 372 platform/graphics/ct/FontCascadeCoreText.cpp 373 platform/graphics/ct/FontCoreText.cpp 374 platform/graphics/ct/FontPlatformDataCoreText.cpp 375 platform/graphics/ct/GlyphPageCoreText.cpp 372 376 platform/graphics/cv/ImageTransferSessionVT.mm 373 377 platform/graphics/cv/PixelBufferConformerCV.cpp … … 403 407 platform/graphics/mac/FloatSizeMac.mm 404 408 platform/graphics/mac/FontCustomPlatformData.cpp 405 platform/graphics/mac/GlyphPageMac.cpp406 409 platform/graphics/mac/IconMac.mm 407 410 platform/graphics/mac/ImageMac.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r266926 r266936 6641 6641 1C66260F1C6E7CA600AB527C /* FontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFace.h; sourceTree = "<group>"; }; 6642 6642 1C6B95DD22C858A400E6F14F /* WHLSLBuildStandardLibraryFunctionMap.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = WHLSLBuildStandardLibraryFunctionMap.py; sourceTree = "<group>"; }; 6643 1C6FD8AC250A294D00D6E920 /* FontPlatformDataCoreText.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontPlatformDataCoreText.cpp; sourceTree = "<group>"; }; 6644 1C6FD8AD250A2E5300D6E920 /* GlyphPageCoreText.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GlyphPageCoreText.cpp; sourceTree = "<group>"; }; 6645 1C6FD8AE250A311500D6E920 /* FontCascadeCoreText.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontCascadeCoreText.cpp; sourceTree = "<group>"; }; 6646 1C6FD8AF250A33CF00D6E920 /* FontCoreText.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontCoreText.cpp; sourceTree = "<group>"; }; 6647 1C6FD8B0250A35F100D6E920 /* FontCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FontCocoa.cpp; sourceTree = "<group>"; }; 6643 6648 1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; }; 6644 6649 1C81B9570E97330800266E07 /* InspectorController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorController.cpp; sourceTree = "<group>"; }; … … 10175 10180 7C4C96DB1AD4483500363572 /* JSReadableStreamBYOBReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamBYOBReader.h; sourceTree = "<group>"; }; 10176 10181 7C4C96DB1AD4483500365A50 /* JSReadableStreamDefaultReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamDefaultReader.h; sourceTree = "<group>"; }; 10177 7C4EDD731A7B607800198C4D /* FontCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FontCocoa.mm; sourceTree = "<group>"; };10178 10182 7C514E0024AF80580050710F /* ColorConversion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorConversion.h; sourceTree = "<group>"; }; 10179 10183 7C514E0224AF80580050710F /* ColorConversion.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ColorConversion.cpp; sourceTree = "<group>"; }; … … 13147 13151 B2AFFC760D00A5C10030074D /* FontCustomPlatformData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontCustomPlatformData.h; sourceTree = "<group>"; }; 13148 13152 B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = FontCascadeCocoa.mm; sourceTree = "<group>"; }; 13149 B2AFFC7B0D00A5C10030074D /* GlyphPageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GlyphPageMac.cpp; sourceTree = "<group>"; };13150 13153 B2AFFC8C0D00A5DF0030074D /* TextBoundaries.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = TextBoundaries.mm; sourceTree = "<group>"; }; 13151 13154 B2B1F7140D00CAA8004AEA64 /* PointerEventsHitRules.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PointerEventsHitRules.cpp; sourceTree = "<group>"; }; … … 18141 18144 sourceTree = "<group>"; 18142 18145 }; 18146 1C6FD8AA250A292400D6E920 /* ct */ = { 18147 isa = PBXGroup; 18148 children = ( 18149 1C6FD8AE250A311500D6E920 /* FontCascadeCoreText.cpp */, 18150 1C6FD8AF250A33CF00D6E920 /* FontCoreText.cpp */, 18151 1C6FD8AC250A294D00D6E920 /* FontPlatformDataCoreText.cpp */, 18152 1C6FD8AD250A2E5300D6E920 /* GlyphPageCoreText.cpp */, 18153 ); 18154 path = ct; 18155 sourceTree = "<group>"; 18156 }; 18143 18157 1C81B94D0E9732D900266E07 /* inspector */ = { 18144 18158 isa = PBXGroup; … … 25829 25843 B2AFFC750D00A5C10030074D /* FontCustomPlatformData.cpp */, 25830 25844 B2AFFC760D00A5C10030074D /* FontCustomPlatformData.h */, 25831 B2AFFC7B0D00A5C10030074D /* GlyphPageMac.cpp */,25832 25845 B275358D0B053A66002CE64F /* IconMac.mm */, 25833 25846 B275354E0B053814002CE64F /* ImageMac.mm */, … … 25856 25869 2CE1189824C2402C003770E9 /* coreimage */, 25857 25870 9332AB3B16515D7700D827EC /* cpu */, 25871 1C6FD8AA250A292400D6E920 /* ct */, 25858 25872 CD9D827C1C7BB2ED006FF066 /* cv */, 25859 25873 0FE5FBC91C3DD5060007A2CA /* displaylists */, … … 26216 26230 C2458E611FE8979E00594759 /* FontCacheCoreText.h */, 26217 26231 B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */, 26218 7C4EDD731A7B607800198C4D /* FontCocoa.mm*/,26232 1C6FD8B0250A35F100D6E920 /* FontCocoa.cpp */, 26219 26233 1C12AC2C1EE779950079E0A0 /* FontDescriptionCocoa.cpp */, 26220 26234 1C12AC281EE778AE0079E0A0 /* FontFamilySpecificationCoreText.cpp */, -
trunk/Source/WebCore/platform/graphics/Font.cpp
r265487 r266936 475 475 } 476 476 477 #if ! PLATFORM(COCOA)477 #if !USE(CORE_TEXT) 478 478 479 479 bool Font::isProbablyOnlyUsedToRenderIcons() const … … 512 512 } 513 513 514 #if ! PLATFORM(COCOA)514 #if !USE(CORE_TEXT) 515 515 void Font::applyTransforms(GlyphBuffer&, unsigned, unsigned, bool, bool, const AtomString&, StringView, TextDirection) const 516 516 { -
trunk/Source/WebCore/platform/graphics/Font.h
r266692 r266936 65 65 enum class IsForPlatformFont : uint8_t { No, Yes }; 66 66 67 #if PLATFORM(COCOA)67 #if USE(CORE_TEXT) 68 68 bool fontHasTable(CTFontRef, unsigned tableTag); 69 69 bool fontHasEitherTable(CTFontRef, unsigned tableTag1, unsigned tableTag2); -
trunk/Source/WebCore/platform/graphics/FontCascade.cpp
r266688 r266936 596 596 } 597 597 598 #if ! PLATFORM(COCOA)598 #if !USE(CORE_TEXT) 599 599 bool FontCascade::isSubpixelAntialiasingAvailable() 600 600 { -
trunk/Source/WebCore/platform/graphics/FontCascade.h
r265487 r266936 82 82 }; 83 83 84 #if USE(CORE_TEXT) 85 void showLetterpressedGlyphsWithAdvances(const FloatPoint&, const Font&, GraphicsContext&, const CGGlyph*, const CGSize* advances, unsigned count); 86 void fillVectorWithHorizontalGlyphPositions(Vector<CGPoint, 256>& positions, CGContextRef, const CGSize* advances, unsigned count); 87 #endif 88 84 89 class TextLayoutDeleter { 85 90 public: -
trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp
r263527 r266936 85 85 #endif 86 86 87 #if ! PLATFORM(COCOA)87 #if !USE(CORE_TEXT) 88 88 89 89 String FontPlatformData::familyName() const -
trunk/Source/WebCore/platform/graphics/FontPlatformData.h
r266667 r266936 1 1 /* 2 * Copyright (C) 2006-20 18Apple Inc. All rights reserved.2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com 4 4 * Copyright (C) 2007 Holger Hans Peter Freyther … … 50 50 #endif 51 51 52 #if PLATFORM(COCOA)52 #if USE(CORE_TEXT) 53 53 typedef const struct __CTFont* CTFontRef; 54 54 #endif … … 83 83 FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = FontOrientation::Horizontal, FontWidthVariant = FontWidthVariant::RegularWidth, TextRenderingMode = TextRenderingMode::AutoTextRendering); 84 84 85 #if PLATFORM(COCOA)85 #if USE(CORE_TEXT) 86 86 WEBCORE_EXPORT FontPlatformData(CTFontRef, float size, bool syntheticBold = false, bool syntheticOblique = false, FontOrientation = FontOrientation::Horizontal, FontWidthVariant = FontWidthVariant::RegularWidth, TextRenderingMode = TextRenderingMode::AutoTextRendering); 87 87 #endif … … 120 120 #endif 121 121 122 #if PLATFORM(COCOA)122 #if USE(CORE_TEXT) 123 123 CTFontRef font() const { return m_font.get(); } 124 124 WEBCORE_EXPORT CTFontRef registeredFont() const; // Returns nullptr iff the font is not registered, such as web fonts (otherwise returns font()). … … 223 223 #endif 224 224 225 #if PLATFORM(COCOA)225 #if USE(CORE_TEXT) 226 226 // FIXME: Get rid of one of these. These two fonts are subtly different, and it is not obvious which one to use where. 227 227 RetainPtr<CTFontRef> m_font; … … 277 277 }; 278 278 279 #if PLATFORM(COCOA)279 #if USE(CORE_TEXT) 280 280 bool isSystemFont(CTFontRef); 281 281 #endif -
trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm
r266688 r266936 24 24 #import "FontCascade.h" 25 25 26 #import "ComplexTextController.h"27 #import "DashArray.h"28 #import "Font.h"29 #import "GlyphBuffer.h"30 26 #import "GraphicsContext.h" 31 #import "LayoutRect.h"32 #import "Logging.h"33 27 #import <pal/spi/cg/CoreGraphicsSPI.h> 34 #import <pal/spi/cocoa/CoreTextSPI.h>35 #if USE(APPKIT)36 #import <AppKit/AppKit.h>37 #endif38 #import <wtf/MathExtras.h>39 28 40 29 #if PLATFORM(IOS_FAMILY) … … 50 39 namespace WebCore { 51 40 52 // Confusingly, even when CGFontRenderingGetFontSmoothingDisabled() returns true, CGContextSetShouldSmoothFonts() still impacts text53 // rendering, which is why this function uses the "subpixel antialiasing" rather than "smoothing" terminology.54 bool FontCascade::isSubpixelAntialiasingAvailable()55 {56 #if HAVE(CG_FONT_RENDERING_GET_FONT_SMOOTHING_DISABLED)57 static bool subpixelAntialiasingEnabled;58 static std::once_flag onceFlag;59 std::call_once(onceFlag, [&] () {60 subpixelAntialiasingEnabled = !CGFontRenderingGetFontSmoothingDisabled();61 });62 return subpixelAntialiasingEnabled;63 #elif PLATFORM(MAC)64 return true;65 #else66 return false;67 #endif68 }69 70 41 bool FontCascade::canReturnFallbackFontsForComplexText() 71 42 { … … 78 49 } 79 50 80 static inline void fillVectorWithHorizontalGlyphPositions(Vector<CGPoint, 256>& positions, CGContextRef context, const CGSize* advances, unsigned count) 81 { 82 CGAffineTransform matrix = CGAffineTransformInvert(CGContextGetTextMatrix(context)); 83 positions[0] = CGPointZero; 84 for (unsigned i = 1; i < count; ++i) { 85 CGSize advance = CGSizeApplyAffineTransform(advances[i - 1], matrix); 86 positions[i].x = positions[i - 1].x + advance.width; 87 positions[i].y = positions[i - 1].y + advance.height; 88 } 89 } 90 91 static inline bool shouldUseLetterpressEffect(const GraphicsContext& context) 92 { 93 #if ENABLE(LETTERPRESS) 94 return context.textDrawingMode().contains(TextDrawingMode::Letterpress); 95 #else 96 UNUSED_PARAM(context); 97 return false; 98 #endif 99 } 100 101 static void showLetterpressedGlyphsWithAdvances(const FloatPoint& point, const Font& font, GraphicsContext& coreContext, const CGGlyph* glyphs, const CGSize* advances, unsigned count) 51 void showLetterpressedGlyphsWithAdvances(const FloatPoint& point, const Font& font, GraphicsContext& coreContext, const CGGlyph* glyphs, const CGSize* advances, unsigned count) 102 52 { 103 53 #if ENABLE(LETTERPRESS) … … 151 101 } 152 102 153 static void showGlyphsWithAdvances(const FloatPoint& point, const Font& font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, unsigned count)154 {155 if (!count)156 return;157 158 CGContextSetTextPosition(context, point.x(), point.y());159 160 const FontPlatformData& platformData = font.platformData();161 Vector<CGPoint, 256> positions(count);162 if (platformData.orientation() == FontOrientation::Vertical) {163 CGAffineTransform rotateLeftTransform = CGAffineTransformMake(0, -1, 1, 0, 0, 0);164 CGAffineTransform textMatrix = CGContextGetTextMatrix(context);165 CGAffineTransform runMatrix = CGAffineTransformConcat(textMatrix, rotateLeftTransform);166 ScopedTextMatrix savedMatrix(runMatrix, context);167 168 Vector<CGSize, 256> translations(count);169 CTFontGetVerticalTranslationsForGlyphs(platformData.ctFont(), glyphs, translations.data(), count);170 171 CGAffineTransform transform = CGAffineTransformInvert(CGContextGetTextMatrix(context));172 173 CGPoint position = FloatPoint(point.x(), point.y() + font.fontMetrics().floatAscent(IdeographicBaseline) - font.fontMetrics().floatAscent());174 for (unsigned i = 0; i < count; ++i) {175 CGSize translation = CGSizeApplyAffineTransform(translations[i], rotateLeftTransform);176 positions[i] = CGPointApplyAffineTransform(CGPointMake(position.x - translation.width, position.y + translation.height), transform);177 position.x += advances[i].width;178 position.y += advances[i].height;179 }180 CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);181 } else {182 fillVectorWithHorizontalGlyphPositions(positions, context, advances, count);183 CTFontDrawGlyphs(platformData.ctFont(), glyphs, positions.data(), count, context);184 }185 103 } 186 187 static void setCGFontRenderingMode(GraphicsContext& context)188 {189 CGContextRef cgContext = context.platformContext();190 CGContextSetShouldAntialiasFonts(cgContext, true);191 192 CGAffineTransform contextTransform = CGContextGetCTM(cgContext);193 bool isTranslationOrIntegralScale = WTF::isIntegral(contextTransform.a) && WTF::isIntegral(contextTransform.d) && contextTransform.b == 0.f && contextTransform.c == 0.f;194 bool isRotated = ((contextTransform.b || contextTransform.c) && (contextTransform.a || contextTransform.d));195 bool doSubpixelQuantization = isTranslationOrIntegralScale || (!isRotated && context.shouldSubpixelQuantizeFonts());196 197 CGContextSetShouldSubpixelPositionFonts(cgContext, true);198 CGContextSetShouldSubpixelQuantizeFonts(cgContext, doSubpixelQuantization);199 }200 201 void FontCascade::drawGlyphs(GraphicsContext& context, const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode smoothingMode)202 {203 const FontPlatformData& platformData = font.platformData();204 if (!platformData.size())205 return;206 207 CGContextRef cgContext = context.platformContext();208 209 bool shouldAntialias = true;210 bool shouldSmoothFonts = true;211 212 if (!font.allowsAntialiasing())213 smoothingMode = FontSmoothingMode::NoSmoothing;214 215 switch (smoothingMode) {216 case FontSmoothingMode::Antialiased:217 shouldSmoothFonts = false;218 break;219 case FontSmoothingMode::AutoSmoothing:220 case FontSmoothingMode::SubpixelAntialiased:221 shouldAntialias = true;222 break;223 case FontSmoothingMode::NoSmoothing:224 shouldAntialias = false;225 shouldSmoothFonts = false;226 break;227 }228 229 if (!shouldUseSmoothing())230 shouldSmoothFonts = false;231 232 #if !PLATFORM(IOS_FAMILY)233 bool originalShouldUseFontSmoothing = CGContextGetShouldSmoothFonts(cgContext);234 if (shouldSmoothFonts != originalShouldUseFontSmoothing)235 CGContextSetShouldSmoothFonts(cgContext, shouldSmoothFonts);236 #endif237 238 bool originalShouldAntialias = CGContextGetShouldAntialias(cgContext);239 if (shouldAntialias != originalShouldAntialias)240 CGContextSetShouldAntialias(cgContext, shouldAntialias);241 242 bool useLetterpressEffect = shouldUseLetterpressEffect(context);243 FloatPoint point = anchorPoint;244 245 CGAffineTransform matrix = CGAffineTransformIdentity;246 if (!platformData.isColorBitmapFont())247 matrix = CTFontGetMatrix(platformData.font());248 matrix.b = -matrix.b;249 matrix.d = -matrix.d;250 if (platformData.syntheticOblique()) {251 static float obliqueSkew = tanf(syntheticObliqueAngle() * piFloat / 180);252 if (platformData.orientation() == FontOrientation::Vertical) {253 if (font.isTextOrientationFallback())254 matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, obliqueSkew, 0, 1, 0, 0));255 else256 matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, -obliqueSkew, 0, 1, 0, 0));257 } else258 matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, 0, -obliqueSkew, 1, 0, 0));259 }260 ScopedTextMatrix restorer(matrix, cgContext);261 262 setCGFontRenderingMode(context);263 CGContextSetFontSize(cgContext, platformData.size());264 265 FloatSize shadowOffset;266 float shadowBlur;267 Color shadowColor;268 context.getShadow(shadowOffset, shadowBlur, shadowColor);269 270 AffineTransform contextCTM = context.getCTM();271 float syntheticBoldOffset = font.syntheticBoldOffset();272 if (syntheticBoldOffset && !contextCTM.isIdentityOrTranslationOrFlipped()) {273 FloatSize horizontalUnitSizeInDevicePixels = contextCTM.mapSize(FloatSize(1, 0));274 float horizontalUnitLengthInDevicePixels = sqrtf(horizontalUnitSizeInDevicePixels.width() * horizontalUnitSizeInDevicePixels.width() + horizontalUnitSizeInDevicePixels.height() * horizontalUnitSizeInDevicePixels.height());275 if (horizontalUnitLengthInDevicePixels) {276 // Make sure that a scaled down context won't blow up the gap between the glyphs.277 syntheticBoldOffset = std::min(syntheticBoldOffset, syntheticBoldOffset / horizontalUnitLengthInDevicePixels);278 }279 };280 281 bool hasSimpleShadow = context.textDrawingMode() == TextDrawingMode::Fill && shadowColor.isValid() && !shadowBlur && !platformData.isColorBitmapFont() && (!context.shadowsIgnoreTransforms() || contextCTM.isIdentityOrTranslationOrFlipped()) && !context.isInTransparencyLayer();282 if (hasSimpleShadow) {283 // Paint simple shadows ourselves instead of relying on CG shadows, to avoid losing subpixel antialiasing.284 context.clearShadow();285 Color fillColor = context.fillColor();286 Color shadowFillColor = shadowColor.colorWithAlphaMultipliedBy(fillColor.alphaAsFloat());287 context.setFillColor(shadowFillColor);288 float shadowTextX = point.x() + shadowOffset.width();289 // If shadows are ignoring transforms, then we haven't applied the Y coordinate flip yet, so down is negative.290 float shadowTextY = point.y() + shadowOffset.height() * (context.shadowsIgnoreTransforms() ? -1 : 1);291 showGlyphsWithAdvances(FloatPoint(shadowTextX, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);292 if (syntheticBoldOffset)293 showGlyphsWithAdvances(FloatPoint(shadowTextX + syntheticBoldOffset, shadowTextY), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);294 context.setFillColor(fillColor);295 }296 297 if (useLetterpressEffect)298 showLetterpressedGlyphsWithAdvances(point, font, context, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);299 else300 showGlyphsWithAdvances(point, font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);301 if (syntheticBoldOffset)302 showGlyphsWithAdvances(FloatPoint(point.x() + syntheticBoldOffset, point.y()), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);303 304 if (hasSimpleShadow)305 context.setShadow(shadowOffset, shadowBlur, shadowColor);306 307 #if !PLATFORM(IOS_FAMILY)308 if (shouldSmoothFonts != originalShouldUseFontSmoothing)309 CGContextSetShouldSmoothFonts(cgContext, originalShouldUseFontSmoothing);310 #endif311 312 if (shouldAntialias != originalShouldAntialias)313 CGContextSetShouldAntialias(cgContext, originalShouldAntialias);314 }315 316 bool FontCascade::primaryFontIsSystemFont() const317 {318 const auto& fontData = primaryFont();319 return isSystemFont(fontData.platformData().ctFont());320 }321 322 // FIXME: Use this on all ports.323 const Font* FontCascade::fontForCombiningCharacterSequence(const UChar* characters, size_t length) const324 {325 UChar32 baseCharacter;326 size_t baseCharacterLength = 0;327 U16_NEXT(characters, baseCharacterLength, length, baseCharacter);328 329 GlyphData baseCharacterGlyphData = glyphDataForCharacter(baseCharacter, false, NormalVariant);330 331 if (!baseCharacterGlyphData.glyph)332 return nullptr;333 334 if (length == baseCharacterLength)335 return baseCharacterGlyphData.font;336 337 bool triedBaseCharacterFont = false;338 339 for (unsigned i = 0; !fallbackRangesAt(i).isNull(); ++i) {340 const Font* font = fallbackRangesAt(i).fontForCharacter(baseCharacter);341 if (!font)342 continue;343 #if PLATFORM(IOS_FAMILY)344 if (baseCharacter >= 0x0600 && baseCharacter <= 0x06ff && font->shouldNotBeUsedForArabic())345 continue;346 #endif347 if (font->platformData().orientation() == FontOrientation::Vertical) {348 if (isCJKIdeographOrSymbol(baseCharacter) && !font->hasVerticalGlyphs())349 font = &font->brokenIdeographFont();350 else if (m_fontDescription.nonCJKGlyphOrientation() == NonCJKGlyphOrientation::Mixed) {351 const Font& verticalRightFont = font->verticalRightOrientationFont();352 Glyph verticalRightGlyph = verticalRightFont.glyphForCharacter(baseCharacter);353 if (verticalRightGlyph == baseCharacterGlyphData.glyph)354 font = &verticalRightFont;355 } else {356 const Font& uprightFont = font->uprightOrientationFont();357 Glyph uprightGlyph = uprightFont.glyphForCharacter(baseCharacter);358 if (uprightGlyph != baseCharacterGlyphData.glyph)359 font = &uprightFont;360 }361 }362 363 if (font == baseCharacterGlyphData.font)364 triedBaseCharacterFont = true;365 366 if (font->canRenderCombiningCharacterSequence(characters, length))367 return font;368 }369 370 if (!triedBaseCharacterFont && baseCharacterGlyphData.font && baseCharacterGlyphData.font->canRenderCombiningCharacterSequence(characters, length))371 return baseCharacterGlyphData.font;372 373 return Font::systemFallback();374 }375 376 } -
trunk/Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
r266667 r266936 36 36 namespace WebCore { 37 37 38 bool isSystemFont(CTFontRef font)39 {40 #if HAVE(CTFONTISSYSTEMUIFONT)41 return CTFontIsSystemUIFont(font);42 #else43 return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get());44 #endif45 }46 47 // These CoreText Text Spacing feature selectors are not defined in CoreText.48 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidth, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth };49 50 FontPlatformData::FontPlatformData(CTFontRef font, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode)51 : FontPlatformData(size, syntheticBold, syntheticOblique, orientation, widthVariant, textRenderingMode)52 {53 ASSERT_ARG(font, font);54 m_font = font;55 m_isColorBitmapFont = CTFontGetSymbolicTraits(font) & kCTFontTraitColorGlyphs;56 m_isSystemFont = WebCore::isSystemFont(m_font.get());57 auto variations = adoptCF(static_cast<CFDictionaryRef>(CTFontCopyAttribute(font, kCTFontVariationAttribute)));58 m_hasVariations = variations && CFDictionaryGetCount(variations.get());59 60 #if PLATFORM(IOS_FAMILY)61 m_isEmoji = CTFontIsAppleColorEmoji(m_font.get());62 #endif63 }64 65 38 unsigned FontPlatformData::hash() const 66 39 { … … 72 45 | m_syntheticOblique); 73 46 74 uintptr_t fontHash = reinterpret_cast<uintptr_t>(CFHash(m_font.get()));47 uintptr_t fontHash = static_cast<uintptr_t>(CFHash(m_font.get())); 75 48 uintptr_t hashCodes[] = { fontHash, flags }; 76 49 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); … … 84 57 } 85 58 86 CTFontRef FontPlatformData::registeredFont() const87 {88 CTFontRef platformFont = font();89 ASSERT(platformFont);90 if (platformFont && adoptCF(CTFontCopyAttribute(platformFont, kCTFontURLAttribute)))91 return platformFont;92 return nullptr;93 }94 95 inline int mapFontWidthVariantToCTFeatureSelector(FontWidthVariant variant)96 {97 switch(variant) {98 case FontWidthVariant::RegularWidth:99 return TextSpacingProportional;100 101 case FontWidthVariant::HalfWidth:102 return TextSpacingHalfWidth;103 104 case FontWidthVariant::ThirdWidth:105 return TextSpacingThirdWidth;106 107 case FontWidthVariant::QuarterWidth:108 return TextSpacingQuarterWidth;109 }110 111 ASSERT_NOT_REACHED();112 return TextSpacingProportional;113 }114 115 static RetainPtr<CFDictionaryRef> cascadeToLastResortAttributesDictionary()116 {117 auto lastResort = adoptCF(CTFontDescriptorCreateWithNameAndSize(CFSTR("LastResort"), 0));118 119 CFTypeRef descriptors[] = { lastResort.get() };120 RetainPtr<CFArrayRef> array = adoptCF(CFArrayCreate(kCFAllocatorDefault, descriptors, WTF_ARRAY_LENGTH(descriptors), &kCFTypeArrayCallBacks));121 122 CFTypeRef keys[] = { kCTFontCascadeListAttribute };123 CFTypeRef values[] = { array.get() };124 return adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));125 }126 127 static CTFontDescriptorRef cascadeToLastResortAndVariationsFontDescriptor()128 {129 static CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes(cascadeToLastResortAttributesDictionary().get());130 return descriptor;131 }132 133 CTFontRef FontPlatformData::ctFont() const134 {135 if (m_ctFont)136 return m_ctFont.get();137 138 ASSERT(m_font);139 m_ctFont = adoptCF(CTFontCreateCopyWithAttributes(m_font.get(), m_size, nullptr, cascadeToLastResortAndVariationsFontDescriptor()));140 141 if (m_widthVariant != FontWidthVariant::RegularWidth) {142 int featureTypeValue = kTextSpacingType;143 int featureSelectorValue = mapFontWidthVariantToCTFeatureSelector(m_widthVariant);144 RetainPtr<CTFontDescriptorRef> sourceDescriptor = adoptCF(CTFontCopyFontDescriptor(m_ctFont.get()));145 RetainPtr<CFNumberRef> featureType = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &featureTypeValue));146 RetainPtr<CFNumberRef> featureSelector = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &featureSelectorValue));147 RetainPtr<CTFontDescriptorRef> newDescriptor = adoptCF(CTFontDescriptorCreateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.get()));148 RetainPtr<CTFontRef> newFont = adoptCF(CTFontCreateWithFontDescriptor(newDescriptor.get(), m_size, 0));149 150 if (newFont)151 m_ctFont = newFont;152 }153 154 return m_ctFont.get();155 }156 157 RetainPtr<CFTypeRef> FontPlatformData::objectForEqualityCheck(CTFontRef ctFont)158 {159 auto fontDescriptor = adoptCF(CTFontCopyFontDescriptor(ctFont));160 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=138683 This is a shallow pointer compare for web fonts161 // because the URL contains the address of the font. This means we might erroneously get false negatives.162 RetainPtr<CFURLRef> url = adoptCF(static_cast<CFURLRef>(CTFontDescriptorCopyAttribute(fontDescriptor.get(), kCTFontReferenceURLAttribute)));163 ASSERT(!url || CFGetTypeID(url.get()) == CFURLGetTypeID());164 return url;165 }166 167 RetainPtr<CFTypeRef> FontPlatformData::objectForEqualityCheck() const168 {169 return objectForEqualityCheck(ctFont());170 }171 172 RefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const173 {174 if (RetainPtr<CFDataRef> data = adoptCF(CTFontCopyTable(font(), table, kCTFontTableOptionNoOptions)))175 return SharedBuffer::create(data.get());176 177 return nullptr;178 }179 180 #if !LOG_DISABLED181 182 String FontPlatformData::description() const183 {184 String fontDescription { adoptCF(CFCopyDescription(font())).get() };185 return makeString(fontDescription, ' ', m_size,186 (m_syntheticBold ? " synthetic bold" : ""),187 (m_syntheticOblique ? " synthetic oblique" : ""),188 (m_orientation == FontOrientation::Vertical ? " vertical orientation" : ""));189 }190 191 #endif192 193 String FontPlatformData::familyName() const194 {195 if (auto platformFont = font())196 return adoptCF(CTFontCopyFamilyName(platformFont)).get();197 return { };198 }199 200 59 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp
r265962 r266936 53 53 54 54 namespace WebCore { 55 56 // FIXME: Remove this once kCMVideoCodecType_VP9 is added to CMFormatDescription.h57 constexpr CMVideoCodecType kCMVideoCodecType_VP9 { 'vp09' };58 55 59 56 using namespace PAL; -
trunk/Source/WebCore/platform/graphics/ct/FontCascadeCoreText.cpp
r266934 r266936 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2000 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2003, 2006-20 11, 2016 Apple Inc.5 * Copyright (C) 2003, 2006-2020, 2016 Apple Inc. 6 6 * 7 7 * This library is free software; you can redistribute it and/or … … 21 21 */ 22 22 23 #import "config.h" 24 #import "FontCascade.h" 25 26 #import "ComplexTextController.h" 27 #import "DashArray.h" 28 #import "Font.h" 29 #import "GlyphBuffer.h" 30 #import "GraphicsContext.h" 31 #import "LayoutRect.h" 32 #import "Logging.h" 33 #import <pal/spi/cg/CoreGraphicsSPI.h> 34 #import <pal/spi/cocoa/CoreTextSPI.h> 35 #if USE(APPKIT) 36 #import <AppKit/AppKit.h> 37 #endif 38 #import <wtf/MathExtras.h> 39 40 #if PLATFORM(IOS_FAMILY) 41 #import <pal/ios/UIKitSoftLink.h> 42 #import <pal/spi/ios/CoreUISPI.h> 43 #import <wtf/SoftLinking.h> 44 45 SOFT_LINK_PRIVATE_FRAMEWORK(CoreUI) 46 SOFT_LINK_CLASS(CoreUI, CUICatalog) 47 SOFT_LINK_CLASS(CoreUI, CUIStyleEffectConfiguration) 23 #include "config.h" 24 #include "FontCascade.h" 25 26 #include "ComplexTextController.h" 27 #include "DashArray.h" 28 #include "Font.h" 29 #include "GlyphBuffer.h" 30 #include "GraphicsContext.h" 31 #include "LayoutRect.h" 32 #include "Logging.h" 33 #include <pal/spi/cg/CoreGraphicsSPI.h> 34 #include <wtf/MathExtras.h> 35 36 #if PLATFORM(COCOA) 37 #include <pal/spi/cocoa/CoreTextSPI.h> 38 #else 39 #include <pal/spi/win/CoreTextSPIWin.h> 48 40 #endif 49 41 … … 57 49 static bool subpixelAntialiasingEnabled; 58 50 static std::once_flag onceFlag; 59 std::call_once(onceFlag, [&] 51 std::call_once(onceFlag, [&]() { 60 52 subpixelAntialiasingEnabled = !CGFontRenderingGetFontSmoothingDisabled(); 61 53 }); … … 68 60 } 69 61 70 bool FontCascade::canReturnFallbackFontsForComplexText() 71 { 72 return true; 73 } 74 75 bool FontCascade::canExpandAroundIdeographsInComplexText() 76 { 77 return true; 78 } 79 80 static inline void fillVectorWithHorizontalGlyphPositions(Vector<CGPoint, 256>& positions, CGContextRef context, const CGSize* advances, unsigned count) 62 void fillVectorWithHorizontalGlyphPositions(Vector<CGPoint, 256>& positions, CGContextRef context, const CGSize* advances, unsigned count) 81 63 { 82 64 CGAffineTransform matrix = CGAffineTransformInvert(CGContextGetTextMatrix(context)); … … 96 78 UNUSED_PARAM(context); 97 79 return false; 98 #endif99 }100 101 static void showLetterpressedGlyphsWithAdvances(const FloatPoint& point, const Font& font, GraphicsContext& coreContext, const CGGlyph* glyphs, const CGSize* advances, unsigned count)102 {103 #if ENABLE(LETTERPRESS)104 if (!count)105 return;106 107 const FontPlatformData& platformData = font.platformData();108 if (platformData.orientation() == FontOrientation::Vertical) {109 // FIXME: Implement support for vertical text. See <rdar://problem/13737298>.110 return;111 }112 113 CGContextRef context = coreContext.platformContext();114 115 CGContextSetTextPosition(context, point.x(), point.y());116 Vector<CGPoint, 256> positions(count);117 fillVectorWithHorizontalGlyphPositions(positions, context, advances, count);118 119 CTFontRef ctFont = platformData.ctFont();120 CGContextSetFontSize(context, CTFontGetSize(ctFont));121 122 static CUICatalog *catalog = PAL::softLink_UIKit__UIKitGetTextEffectsCatalog();123 if (!catalog)124 return;125 126 static CUIStyleEffectConfiguration *styleConfiguration;127 if (!styleConfiguration) {128 styleConfiguration = [allocCUIStyleEffectConfigurationInstance() init];129 styleConfiguration.useSimplifiedEffect = YES;130 }131 132 #if HAVE(OS_DARK_MODE_SUPPORT)133 styleConfiguration.appearanceName = coreContext.useDarkAppearance() ? @"UIAppearanceDark" : @"UIAppearanceLight";134 #endif135 136 CGContextSetFont(context, adoptCF(CTFontCopyGraphicsFont(ctFont, nullptr)).get());137 CGContextSetFontSize(context, platformData.size());138 139 [catalog drawGlyphs:glyphs atPositions:positions.data() inContext:context withFont:ctFont count:count stylePresetName:@"_UIKitNewLetterpressStyle" styleConfiguration:styleConfiguration foregroundColor:CGContextGetFillColorAsColor(context)];140 141 CGContextSetFont(context, nullptr);142 CGContextSetFontSize(context, 0);143 #else144 UNUSED_PARAM(point);145 UNUSED_PARAM(font);146 UNUSED_PARAM(coreContext);147 UNUSED_PARAM(glyphs);148 UNUSED_PARAM(advances);149 UNUSED_PARAM(count);150 80 #endif 151 81 } … … 209 139 bool shouldAntialias = true; 210 140 bool shouldSmoothFonts = true; 211 141 212 142 if (!font.allowsAntialiasing()) 213 143 smoothingMode = FontSmoothingMode::NoSmoothing; … … 241 171 242 172 bool useLetterpressEffect = shouldUseLetterpressEffect(context); 173 UNUSED_VARIABLE(useLetterpressEffect); 243 174 FloatPoint point = anchorPoint; 244 175 … … 274 205 float horizontalUnitLengthInDevicePixels = sqrtf(horizontalUnitSizeInDevicePixels.width() * horizontalUnitSizeInDevicePixels.width() + horizontalUnitSizeInDevicePixels.height() * horizontalUnitSizeInDevicePixels.height()); 275 206 if (horizontalUnitLengthInDevicePixels) { 276 // Make sure that a scaled down context won't blow up the gap between the glyphs. 207 // Make sure that a scaled down context won't blow up the gap between the glyphs. 277 208 syntheticBoldOffset = std::min(syntheticBoldOffset, syntheticBoldOffset / horizontalUnitLengthInDevicePixels); 278 209 } … … 295 226 } 296 227 228 #if ENABLE(LETTERPRESS) 297 229 if (useLetterpressEffect) 298 230 showLetterpressedGlyphsWithAdvances(point, font, context, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs); 299 231 else 232 #endif 233 { 300 234 showGlyphsWithAdvances(point, font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs); 235 } 236 301 237 if (syntheticBoldOffset) 302 238 showGlyphsWithAdvances(FloatPoint(point.x() + syntheticBoldOffset, point.y()), font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs); -
trunk/Source/WebCore/platform/graphics/ct/FontCoreText.cpp
r266934 r266936 1 1 /* 2 * Copyright (C) 2005 , 2006, 2010, 2011Apple Inc. All rights reserved.2 * Copyright (C) 2005-2020 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 Alexey Proskuryakov 4 4 * … … 25 25 */ 26 26 27 #import "config.h" 28 #import "Font.h" 29 30 #import "Color.h" 31 #import "FloatRect.h" 32 #import "FontCache.h" 33 #import "FontCascade.h" 34 #import "FontDescription.h" 35 #import "LocaleCocoa.h" 36 #import "OpenTypeCG.h" 37 #import "SharedBuffer.h" 38 #import <CoreText/CoreText.h> 39 #import <float.h> 40 #import <pal/spi/cg/CoreGraphicsSPI.h> 41 #import <pal/spi/cocoa/CoreTextSPI.h> 42 #import <unicode/uchar.h> 43 #import <wtf/Assertions.h> 44 #import <wtf/RetainPtr.h> 45 #import <wtf/StdLibExtras.h> 46 47 #if USE(APPKIT) 48 #import <AppKit/AppKit.h> 49 #endif 50 51 52 #if USE(APPKIT) 53 @interface NSFont (WebAppKitSecretAPI) 54 - (BOOL)_isFakeFixedPitch; 55 @end 27 #include "config.h" 28 #include "Font.h" 29 30 #include "Color.h" 31 #include "FloatRect.h" 32 #include "FontCache.h" 33 #include "FontCascade.h" 34 #include "FontDescription.h" 35 #include "OpenTypeCG.h" 36 #include "SharedBuffer.h" 37 #include <CoreText/CoreText.h> 38 #include <float.h> 39 #include <pal/spi/cg/CoreGraphicsSPI.h> 40 #include <unicode/uchar.h> 41 #include <wtf/Assertions.h> 42 #include <wtf/RetainPtr.h> 43 #include <wtf/StdLibExtras.h> 44 45 #if PLATFORM(COCOA) 46 #include "LocaleCocoa.h" 47 #include <pal/spi/cocoa/CoreTextSPI.h> 48 #else 49 #include <pal/spi/win/CoreTextSPIWin.h> 56 50 #endif 57 51 … … 144 138 #else 145 139 m_syntheticBoldOffset = m_platformData.syntheticBold() ? 1.0f : 0.f; 140 #endif 141 142 #if PLATFORM(WIN) 143 m_scriptCache = 0; 144 m_scriptFontProperties = nullptr; 145 if (m_platformData.useGDI()) 146 return initGDIFont(); 146 147 #endif 147 148 … … 247 248 if (headTable && CFDataGetLength(headTable.get()) >= 42) { 248 249 const UInt8* head = CFDataGetBytePtr(headTable.get()); 249 u shortuxMin = head[36] * 256 + head[37];250 u shortuxMax = head[40] * 256 + head[41];250 unsigned uxMin = head[36] * 256 + head[37]; 251 unsigned uxMax = head[40] * 256 + head[41]; 251 252 SInt16 xMin = static_cast<SInt16>(uxMin); 252 253 SInt16 xMax = static_cast<SInt16>(uxMax); … … 257 258 // Fallback to a cross-platform estimate, which will populate these values if they are non-positive. 258 259 initCharWidths(); 259 }260 261 void Font::platformDestroy()262 {263 260 } 264 261 … … 557 554 float size = m_platformData.size() * scaleFactor; 558 555 CTFontSymbolicTraits fontTraits = CTFontGetSymbolicTraits(m_platformData.font()); 559 autofontDescriptor = adoptCF(CTFontCopyFontDescriptor(m_platformData.font()));556 RetainPtr<CTFontDescriptorRef> fontDescriptor = adoptCF(CTFontCopyFontDescriptor(m_platformData.font())); 560 557 RetainPtr<CTFontRef> scaledFont = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), size, nullptr)); 561 558 … … 569 566 // FIXME: Implement GlyphBuffer initial advance. 570 567 #if USE(CTFONTSHAPEGLYPHS) 571 auto handler = ^(CFRange range, CGGlyph** newGlyphsPointer, CGSize** newAdvancesPointer, CGPoint** newOffsetsPointer, CFIndex** newIndicesPointer) { 568 auto handler = ^(CFRange range, CGGlyph** newGlyphsPointer, CGSize** newAdvancesPointer, CGPoint** newOffsetsPointer, CFIndex** newIndicesPointer) 569 { 572 570 range.location = std::min(std::max(range.location, static_cast<CFIndex>(0)), static_cast<CFIndex>(glyphBuffer.size())); 573 571 if (range.length < 0) { -
trunk/Source/WebCore/platform/graphics/ct/FontPlatformDataCoreText.cpp
r266934 r266936 2 2 * This file is part of the internal font implementation. 3 3 * 4 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 5 * Copyright (c) 2010 Google Inc. All rights reserved. 4 * Copyright (C) 2020 Apple Inc. All rights reserved. 6 5 * 7 6 * This library is free software; you can redistribute it and/or … … 22 21 */ 23 22 24 #i mport"config.h"25 #i mport"FontPlatformData.h"23 #include "config.h" 24 #include "FontPlatformData.h" 26 25 27 #i mport"SharedBuffer.h"28 #i mport <pal/spi/cocoa/CoreTextSPI.h>29 #i mport<wtf/text/StringConcatenateNumbers.h>26 #include "SharedBuffer.h" 27 #include <CoreText/CoreText.h> 28 #include <wtf/text/StringConcatenateNumbers.h> 30 29 31 #if PLATFORM(IOS_FAMILY) 32 #import <CoreText/CoreText.h> 33 #import <pal/spi/cg/CoreGraphicsSPI.h> 30 #if PLATFORM(COCOA) 31 #include <pal/spi/cocoa/CoreTextSPI.h> 32 #else 33 #include <pal/spi/win/CoreTextSPIWin.h> 34 34 #endif 35 35 36 36 namespace WebCore { 37 38 bool isSystemFont(CTFontRef font)39 {40 #if HAVE(CTFONTISSYSTEMUIFONT)41 return CTFontIsSystemUIFont(font);42 #else43 return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get());44 #endif45 }46 47 // These CoreText Text Spacing feature selectors are not defined in CoreText.48 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidth, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth };49 37 50 38 FontPlatformData::FontPlatformData(CTFontRef font, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode) … … 53 41 ASSERT_ARG(font, font); 54 42 m_font = font; 55 m_isColorBitmapFont = CTFontGetSymbolicTraits(font) & kCTFont TraitColorGlyphs;43 m_isColorBitmapFont = CTFontGetSymbolicTraits(font) & kCTFontColorGlyphsTrait; 56 44 m_isSystemFont = WebCore::isSystemFont(m_font.get()); 57 45 auto variations = adoptCF(static_cast<CFDictionaryRef>(CTFontCopyAttribute(font, kCTFontVariationAttribute))); … … 63 51 } 64 52 65 unsigned FontPlatformData::hash() const 53 bool isSystemFont(CTFontRef font) 66 54 { 67 uintptr_t flags = static_cast<uintptr_t>(static_cast<unsigned>(m_widthVariant) << 6 68 | m_isHashTableDeletedValue << 5 69 | static_cast<unsigned>(m_textRenderingMode) << 3 70 | static_cast<unsigned>(m_orientation) << 2 71 | m_syntheticBold << 1 72 | m_syntheticOblique); 73 74 uintptr_t fontHash = reinterpret_cast<uintptr_t>(CFHash(m_font.get())); 75 uintptr_t hashCodes[] = { fontHash, flags }; 76 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); 77 } 78 79 bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const 80 { 81 if (!m_font || !other.m_font) 82 return m_font == other.m_font; 83 return CFEqual(m_font.get(), other.m_font.get()); 55 #if HAVE(CTFONTISSYSTEMUIFONT) 56 return CTFontIsSystemUIFont(font); 57 #else 58 return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get()); 59 #endif 84 60 } 85 61 … … 93 69 } 94 70 71 #if PLATFORM(COCOA) 95 72 inline int mapFontWidthVariantToCTFeatureSelector(FontWidthVariant variant) 96 73 { 97 switch (variant) {74 switch (variant) { 98 75 case FontWidthVariant::RegularWidth: 99 return TextSpacingProportional;76 return kProportionalTextSelector; 100 77 101 78 case FontWidthVariant::HalfWidth: 102 return TextSpacingHalfWidth;79 return kHalfWidthTextSelector; 103 80 104 81 case FontWidthVariant::ThirdWidth: 105 return TextSpacingThirdWidth;82 return kThirdWidthTextSelector; 106 83 107 84 case FontWidthVariant::QuarterWidth: 108 return TextSpacingQuarterWidth;85 return kQuarterWidthTextSelector; 109 86 } 110 87 111 88 ASSERT_NOT_REACHED(); 112 return TextSpacingProportional;89 return kProportionalTextSelector; 113 90 } 114 91 … … 154 131 return m_ctFont.get(); 155 132 } 133 #else 134 CTFontRef FontPlatformData::ctFont() const 135 { 136 return font(); 137 } 138 #endif 156 139 157 140 RetainPtr<CFTypeRef> FontPlatformData::objectForEqualityCheck(CTFontRef ctFont) … … 174 157 if (RetainPtr<CFDataRef> data = adoptCF(CTFontCopyTable(font(), table, kCTFontTableOptionNoOptions))) 175 158 return SharedBuffer::create(data.get()); 176 159 177 160 return nullptr; 178 161 } -
trunk/Source/WebCore/platform/graphics/ct/GlyphPageCoreText.cpp
r266934 r266936 1 1 /* 2 * Copyright (C) 2006 , 2007Apple Inc. All rights reserved.2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 7 7 * 8 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer. 10 10 * 2. Redistributions in binary form must reproduce the above copyright 11 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution. 13 13 * 3. Neither the name of Apple Inc. ("Apple") nor the names of 14 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 15 * from this software without specific prior written permission. 16 16 * 17 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY … … 33 33 #include "FontCascade.h" 34 34 #include <pal/spi/cg/CoreGraphicsSPI.h> 35 36 #if PLATFORM(COCOA) 35 37 #include <pal/spi/cocoa/CoreTextSPI.h> 38 #else 39 #include <pal/spi/win/CoreTextSPIWin.h> 40 #endif 36 41 37 42 namespace WebCore {
Note: See TracChangeset
for help on using the changeset viewer.