Changeset 266936 in webkit


Ignore:
Timestamp:
Sep 11, 2020 1:27:38 PM (4 years ago)
Author:
mmaxfield@apple.com
Message:

[Cocoa] Migrate CoreText-specific code from *Cocoa.mm to *CoreText.cpp
https://bugs.webkit.org/show_bug.cgi?id=216400

Reviewed by Tim Horton.

Source/WebCore:

This is in preparation for sharing the CoreText code with the Apple Windows port.

This patch doesn't actually cause Windows to use this code yet. That will happen
in a series of subsequent patches. This patch is just the first stage.

There isn't any actual behavior change here - it's just moving code around between
files.

This patch also adds a new USE() flag: USE(CORE_TEXT). It migrates CoreText-specific
code from #if PLATFORM(COCOA) to #if USE(CORE_TEXT).

No new tests because there is no behavior change.

  • PlatformMac.cmake:
  • SourcesCocoa.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/Font.cpp:
  • platform/graphics/Font.h:
  • platform/graphics/FontCascade.cpp:
  • platform/graphics/FontCascade.h:
  • platform/graphics/FontPlatformData.cpp:
  • platform/graphics/FontPlatformData.h:
  • platform/graphics/cocoa/FontCascadeCocoa.mm:

(WebCore::showLetterpressedGlyphsWithAdvances):
(WebCore::FontCascade::isSubpixelAntialiasingAvailable): Deleted.
(WebCore::fillVectorWithHorizontalGlyphPositions): Deleted.
(WebCore::shouldUseLetterpressEffect): Deleted.
(WebCore::showGlyphsWithAdvances): Deleted.
(WebCore::setCGFontRenderingMode): Deleted.
(WebCore::FontCascade::drawGlyphs): Deleted.
(WebCore::FontCascade::primaryFontIsSystemFont const): Deleted.
(WebCore::FontCascade::fontForCombiningCharacterSequence const): Deleted.

  • platform/graphics/cocoa/FontCocoa.cpp: Added.

(WebCore::Font::platformDestroy):

  • platform/graphics/cocoa/FontPlatformDataCocoa.mm:

(WebCore::FontPlatformData::hash const):
(WebCore::isSystemFont): Deleted.
(): Deleted.
(WebCore::FontPlatformData::FontPlatformData): Deleted.
(WebCore::FontPlatformData::registeredFont const): Deleted.
(WebCore::mapFontWidthVariantToCTFeatureSelector): Deleted.
(WebCore::cascadeToLastResortAttributesDictionary): Deleted.
(WebCore::cascadeToLastResortAndVariationsFontDescriptor): Deleted.
(WebCore::FontPlatformData::ctFont const): Deleted.
(WebCore::FontPlatformData::objectForEqualityCheck): Deleted.
(WebCore::FontPlatformData::objectForEqualityCheck const): Deleted.
(WebCore::FontPlatformData::openTypeTable const): Deleted.
(WebCore::FontPlatformData::description const): Deleted.
(WebCore::FontPlatformData::familyName const): Deleted.

  • platform/graphics/cocoa/SourceBufferParserWebM.cpp:
  • platform/graphics/ct/FontCascadeCoreText.cpp: Copied from Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm.

(WebCore::FontCascade::isSubpixelAntialiasingAvailable):
(WebCore::fillVectorWithHorizontalGlyphPositions):
(WebCore::shouldUseLetterpressEffect):
(WebCore::showGlyphsWithAdvances):
(WebCore::setCGFontRenderingMode):
(WebCore::FontCascade::drawGlyphs):
(WebCore::FontCascade::primaryFontIsSystemFont const):
(WebCore::FontCascade::fontForCombiningCharacterSequence const):

  • platform/graphics/ct/FontCoreText.cpp: Renamed from Source/WebCore/platform/graphics/cocoa/FontCocoa.mm.

(WebCore::Font::platformInit):
(WebCore::Font::platformCharWidthInit):
(WebCore::Font::platformCreateScaledFont const):
(WebCore::Font::applyTransforms const):

  • platform/graphics/ct/FontPlatformDataCoreText.cpp: Copied from Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm.

(WebCore::FontPlatformData::FontPlatformData):
(WebCore::isSystemFont):
(WebCore::FontPlatformData::registeredFont const):
(WebCore::mapFontWidthVariantToCTFeatureSelector):
(WebCore::cascadeToLastResortAttributesDictionary):
(WebCore::cascadeToLastResortAndVariationsFontDescriptor):
(WebCore::FontPlatformData::ctFont const):
(WebCore::FontPlatformData::objectForEqualityCheck):
(WebCore::FontPlatformData::objectForEqualityCheck const):
(WebCore::FontPlatformData::openTypeTable const):
(WebCore::FontPlatformData::description const):
(WebCore::FontPlatformData::familyName const):

  • platform/graphics/ct/GlyphPageCoreText.cpp: Renamed from Source/WebCore/platform/graphics/mac/GlyphPageMac.cpp.
  • platform/graphics/win/FontCascadeCGWin.cpp: Added.

(WebCore::FontCascade::setFontSmoothingLevel):
(WebCore::setCGFontSmoothingStyle):
(WebCore::FontCascade::setFontSmoothingStyle):
(WebCore::FontCascade::setFontSmoothingContrast):
(WebCore::clearTypeContrast):
(WebCore::FontCascade::systemFontSmoothingChanged):
(WebCore::FontCascade::setCGContextFontRenderingStyle):
(WebCore::renderingStyleForFont):
(WebCore::FontCascade::getPlatformGlyphAdvances):

Source/WebCore/PAL:

  • pal/spi/win/CoreTextSPIWin.h:

Source/WTF:

  • wtf/PlatformUse.h:
Location:
trunk/Source
Files:
3 added
17 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r266929 r266936  
     12020-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
    1102020-09-11  Kate Cheney  <katherine_cheney@apple.com>
    211
  • trunk/Source/WTF/wtf/PlatformUse.h

    r266672 r266936  
    5656
    5757#if PLATFORM(COCOA)
     58#define USE_CORE_TEXT 1
     59#endif
     60
     61#if PLATFORM(COCOA)
    5862#define USE_CA 1
    5963#endif
  • trunk/Source/WebCore/ChangeLog

    r266934 r266936  
     12020-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
    1972020-09-11  Devin Rousso  <drousso@apple.com>
    298
  • trunk/Source/WebCore/PAL/ChangeLog

    r266932 r266936  
     12020-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
    1102020-09-11  Ben Nham  <nham@apple.com>
    211
  • trunk/Source/WebCore/PAL/pal/spi/win/CoreTextSPIWin.h

    r237845 r266936  
    4343CT_EXPORT const CFStringRef kCTStrokeWidthAttributeName;
    4444CT_EXPORT const CFStringRef kCTStrokeColorAttributeName;
     45CT_EXPORT const CFStringRef kCTFontOpenTypeFeatureTag;
     46CT_EXPORT const CFStringRef kCTFontFeatureTypeIdentifierKey;
     47CT_EXPORT const CFStringRef kCTFontOpenTypeFeatureValue;
     48CT_EXPORT const CFStringRef kCTFontFeatureSelectorIdentifierKey;
     49CT_EXPORT const CFStringRef kCTFontFeatureTypeSelectorsKey;
     50CT_EXPORT const CFStringRef kCTFontFeatureSelectorDefaultKey;
     51CT_EXPORT const CFStringRef kCTFontFeatureSettingsAttribute;
     52CT_EXPORT const CFStringRef kCTFontFixedAdvanceAttribute;
     53CT_EXPORT const CFStringRef kCTFontVariationAttribute;
     54CT_EXPORT const CFStringRef kCTFontURLAttribute;
     55CT_EXPORT const CFStringRef kCTFontReferenceURLAttribute;
    4556
    46 // This enum is defined in CTFont.h. To avoid redefinition, only define it here 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.
    4758#ifndef __CTFONT__
     59typedef 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
    4871typedef CF_OPTIONS(uint32_t, CTFontTableOptions) {
    4972    kCTFontTableOptionNoOptions = 0,
    5073    kCTFontTableOptionExcludeSynthetic = (1 << 0)
    5174};
     75
     76enum {
     77    kCTFontTableMATH = 'MATH',
     78    kCTFontTableOS2  = 'OS/2',
     79    kCTFontTableVORG = 'VORG',
     80    kCTFontTableHead = 'head',
     81    kCTFontTableVhea = 'vhea',
     82};
     83
     84typedef CF_OPTIONS(uint32_t, CTFontTransformOptions) {
     85    kCTFontTransformApplyShaping = (1 << 0),
     86    kCTFontTransformApplyPositioning = (1 << 1)
     87};
     88
     89enum {
     90    kLowerCaseType = 37,
     91    kUpperCaseType = 38,
     92};
     93
     94enum {
     95    kDefaultLowerCaseSelector = 0,
     96    kLowerCaseSmallCapsSelector = 1,
     97    kLowerCasePetiteCapsSelector = 2
     98};
     99
     100enum {
     101    kDefaultUpperCaseSelector = 0,
     102    kUpperCaseSmallCapsSelector = 1,
     103    kUpperCasePetiteCapsSelector = 2
     104};
     105
     106enum {
     107    kProportionalTextSelector = 0,
     108    kHalfWidthTextSelector = 2,
     109    kThirdWidthTextSelector = 3,
     110    kQuarterWidthTextSelector = 4,
     111};
     112
     113typedef CF_ENUM(uint32_t, CTFontOrientation)
     114{
     115    kCTFontOrientationDefault = 0,
     116    kCTFontOrientationHorizontal = 1,
     117    kCTFontOrientationVertical = 2,
     118};
    52119#endif
    53120
     121unsigned CTFontGetUnitsPerEm(CTFontRef);
     122CGFloat CTFontGetCapHeight(CTFontRef);
     123CGFloat CTFontGetLeading(CTFontRef);
     124CGFloat CTFontGetAscent(CTFontRef);
     125CGFloat CTFontGetDescent(CTFontRef);
     126CGFloat CTFontGetXHeight(CTFontRef);
     127CGFloat CTFontGetUnderlinePosition(CTFontRef);
     128CGFloat CTFontGetUnderlineThickness(CTFontRef);
     129CGFloat CTFontGetSize(CTFontRef);
     130CTFontSymbolicTraits CTFontGetSymbolicTraits(CTFontRef);
     131CFCharacterSetRef CTFontCopyCharacterSet(CTFontRef);
     132CFStringRef CTFontCopyFamilyName(CTFontRef);
     133CFStringRef CTFontCopyFullName(CTFontRef);
     134CTFontRef CTFontCreateCopyWithAttributes(CTFontRef, CGFloat size, const CGAffineTransform* matrix, CTFontDescriptorRef attributes);
    54135CTFontRef CTFontCreateWithName(CFStringRef, CGFloat size, const CGAffineTransform*);
    55136CTFontRef CTFontCreateWithGraphicsFont(CGFontRef, CGFloat size, const CGAffineTransform*, CTFontDescriptorRef attributes);
     137CTFontRef CTFontCreateWithFontDescriptor(CTFontDescriptorRef, CGFloat size, const CGAffineTransform*);
    56138CTLineRef CTLineCreateWithAttributedString(CFAttributedStringRef);
    57139void CTLineDraw(CTLineRef, CGContextRef);
     
    59141CFArrayRef CTFontCopyAvailableTables(CTFontRef, CTFontTableOptions);
    60142CGPathRef CTFontCreatePathForGlyph(CTFontRef, CGGlyph, const CGAffineTransform*);
     143void CTFontGetVerticalTranslationsForGlyphs(CTFontRef, const CGGlyph[], CGSize translations[], CFIndex count);
     144void CTFontDrawGlyphs(CTFontRef, const CGGlyph[], const CGPoint[], size_t count, CGContextRef);
     145CGAffineTransform CTFontGetMatrix(CTFontRef);
     146CFArrayRef CTFontCopyFeatures(CTFontRef);
     147CFTypeRef CTFontCopyAttribute(CTFontRef, CFStringRef);
     148CTFontDescriptorRef CTFontCopyFontDescriptor(CTFontRef);
     149bool CTFontTransformGlyphs(CTFontRef, CGGlyph[], CGSize advances[], CFIndex count, CTFontTransformOptions);
     150CGRect CTFontGetBoundingRectsForGlyphs(CTFontRef, CTFontOrientation, const CGGlyph[], CGRect boundingRects[], CFIndex count);
     151double CTFontGetAdvancesForGlyphs(CTFontRef, CTFontOrientation, const CGGlyph[], CGSize advances[], CFIndex count);
     152bool CTFontGetGlyphsForCharacters(CTFontRef, const UniChar[], CGGlyph[], CFIndex count);
     153bool CTFontGetGlyphsForCharacterRange(CTFontRef, CGGlyph[], CFRange);
     154CFDataRef CTFontCopyTable(CTFontRef, CTFontTableTag, CTFontTableOptions);
     155bool CTFontGetVerticalGlyphsForCharacters(CTFontRef, const UniChar[], CGGlyph[], CFIndex count);
     156
     157CTFontDescriptorRef CTFontDescriptorCreateWithAttributes(CFDictionaryRef);
     158bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef);
     159CTFontDescriptorRef CTFontDescriptorCreateWithNameAndSize(CFStringRef, CGFloat);
    61160
    62161WTF_EXTERN_C_END
  • trunk/Source/WebCore/PlatformMac.cmake

    r266663 r266936  
    307307    platform/graphics/cocoa/FontCacheCoreText.cpp
    308308    platform/graphics/cocoa/FontCascadeCocoa.mm
    309     platform/graphics/cocoa/FontCocoa.mm
     309    platform/graphics/cocoa/FontCocoa.cpp
    310310    platform/graphics/cocoa/FontDescriptionCocoa.cpp
    311311    platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp
     
    322322    platform/graphics/cocoa/WebGPULayer.mm
    323323
     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
    324329    platform/graphics/cv/ImageRotationSessionVT.mm
    325330    platform/graphics/cv/PixelBufferConformerCV.cpp
     
    336341    platform/graphics/mac/FloatSizeMac.mm
    337342    platform/graphics/mac/FontCustomPlatformData.cpp
    338     platform/graphics/mac/GlyphPageMac.cpp
    339343    platform/graphics/mac/IconMac.mm
    340344    platform/graphics/mac/ImageMac.mm
  • trunk/Source/WebCore/SourcesCocoa.txt

    r266673 r266936  
    348348platform/graphics/cocoa/FontCacheCoreText.cpp
    349349platform/graphics/cocoa/FontCascadeCocoa.mm
    350 platform/graphics/cocoa/FontCocoa.mm
     350platform/graphics/cocoa/FontCocoa.cpp
    351351platform/graphics/cocoa/FontDescriptionCocoa.cpp
    352352platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp
     
    370370platform/graphics/cocoa/WebGPULayer.mm
    371371platform/graphics/cocoa/VideoTrackPrivateWebM.cpp
     372platform/graphics/ct/FontCascadeCoreText.cpp
     373platform/graphics/ct/FontCoreText.cpp
     374platform/graphics/ct/FontPlatformDataCoreText.cpp
     375platform/graphics/ct/GlyphPageCoreText.cpp
    372376platform/graphics/cv/ImageTransferSessionVT.mm
    373377platform/graphics/cv/PixelBufferConformerCV.cpp
     
    403407platform/graphics/mac/FloatSizeMac.mm
    404408platform/graphics/mac/FontCustomPlatformData.cpp
    405 platform/graphics/mac/GlyphPageMac.cpp
    406409platform/graphics/mac/IconMac.mm
    407410platform/graphics/mac/ImageMac.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r266926 r266936  
    66416641                1C66260F1C6E7CA600AB527C /* FontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFace.h; sourceTree = "<group>"; };
    66426642                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>"; };
    66436648                1C81B9560E97330800266E07 /* InspectorController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorController.h; sourceTree = "<group>"; };
    66446649                1C81B9570E97330800266E07 /* InspectorController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorController.cpp; sourceTree = "<group>"; };
     
    1017510180                7C4C96DB1AD4483500363572 /* JSReadableStreamBYOBReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamBYOBReader.h; sourceTree = "<group>"; };
    1017610181                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>"; };
    1017810182                7C514E0024AF80580050710F /* ColorConversion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorConversion.h; sourceTree = "<group>"; };
    1017910183                7C514E0224AF80580050710F /* ColorConversion.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ColorConversion.cpp; sourceTree = "<group>"; };
     
    1314713151                B2AFFC760D00A5C10030074D /* FontCustomPlatformData.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontCustomPlatformData.h; sourceTree = "<group>"; };
    1314813152                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>"; };
    1315013153                B2AFFC8C0D00A5DF0030074D /* TextBoundaries.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = TextBoundaries.mm; sourceTree = "<group>"; };
    1315113154                B2B1F7140D00CAA8004AEA64 /* PointerEventsHitRules.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PointerEventsHitRules.cpp; sourceTree = "<group>"; };
     
    1814118144                        sourceTree = "<group>";
    1814218145                };
     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                };
    1814318157                1C81B94D0E9732D900266E07 /* inspector */ = {
    1814418158                        isa = PBXGroup;
     
    2582925843                                B2AFFC750D00A5C10030074D /* FontCustomPlatformData.cpp */,
    2583025844                                B2AFFC760D00A5C10030074D /* FontCustomPlatformData.h */,
    25831                                 B2AFFC7B0D00A5C10030074D /* GlyphPageMac.cpp */,
    2583225845                                B275358D0B053A66002CE64F /* IconMac.mm */,
    2583325846                                B275354E0B053814002CE64F /* ImageMac.mm */,
     
    2585625869                                2CE1189824C2402C003770E9 /* coreimage */,
    2585725870                                9332AB3B16515D7700D827EC /* cpu */,
     25871                                1C6FD8AA250A292400D6E920 /* ct */,
    2585825872                                CD9D827C1C7BB2ED006FF066 /* cv */,
    2585925873                                0FE5FBC91C3DD5060007A2CA /* displaylists */,
     
    2621626230                                C2458E611FE8979E00594759 /* FontCacheCoreText.h */,
    2621726231                                B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
    26218                                 7C4EDD731A7B607800198C4D /* FontCocoa.mm */,
     26232                                1C6FD8B0250A35F100D6E920 /* FontCocoa.cpp */,
    2621926233                                1C12AC2C1EE779950079E0A0 /* FontDescriptionCocoa.cpp */,
    2622026234                                1C12AC281EE778AE0079E0A0 /* FontFamilySpecificationCoreText.cpp */,
  • trunk/Source/WebCore/platform/graphics/Font.cpp

    r265487 r266936  
    475475}
    476476
    477 #if !PLATFORM(COCOA)
     477#if !USE(CORE_TEXT)
    478478
    479479bool Font::isProbablyOnlyUsedToRenderIcons() const
     
    512512}
    513513
    514 #if !PLATFORM(COCOA)
     514#if !USE(CORE_TEXT)
    515515void Font::applyTransforms(GlyphBuffer&, unsigned, unsigned, bool, bool, const AtomString&, StringView, TextDirection) const
    516516{
  • trunk/Source/WebCore/platform/graphics/Font.h

    r266692 r266936  
    6565enum class IsForPlatformFont : uint8_t { No, Yes };
    6666
    67 #if PLATFORM(COCOA)
     67#if USE(CORE_TEXT)
    6868bool fontHasTable(CTFontRef, unsigned tableTag);
    6969bool fontHasEitherTable(CTFontRef, unsigned tableTag1, unsigned tableTag2);
  • trunk/Source/WebCore/platform/graphics/FontCascade.cpp

    r266688 r266936  
    596596}
    597597
    598 #if !PLATFORM(COCOA)
     598#if !USE(CORE_TEXT)
    599599bool FontCascade::isSubpixelAntialiasingAvailable()
    600600{
  • trunk/Source/WebCore/platform/graphics/FontCascade.h

    r265487 r266936  
    8282};
    8383
     84#if USE(CORE_TEXT)
     85void showLetterpressedGlyphsWithAdvances(const FloatPoint&, const Font&, GraphicsContext&, const CGGlyph*, const CGSize* advances, unsigned count);
     86void fillVectorWithHorizontalGlyphPositions(Vector<CGPoint, 256>& positions, CGContextRef, const CGSize* advances, unsigned count);
     87#endif
     88
    8489class TextLayoutDeleter {
    8590public:
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp

    r263527 r266936  
    8585#endif
    8686
    87 #if !PLATFORM(COCOA)
     87#if !USE(CORE_TEXT)
    8888
    8989String FontPlatformData::familyName() const
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.h

    r266667 r266936  
    11/*
    2  * Copyright (C) 2006-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
    44 * Copyright (C) 2007 Holger Hans Peter Freyther
     
    5050#endif
    5151
    52 #if PLATFORM(COCOA)
     52#if USE(CORE_TEXT)
    5353typedef const struct __CTFont* CTFontRef;
    5454#endif
     
    8383    FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = FontOrientation::Horizontal, FontWidthVariant = FontWidthVariant::RegularWidth, TextRenderingMode = TextRenderingMode::AutoTextRendering);
    8484
    85 #if PLATFORM(COCOA)
     85#if USE(CORE_TEXT)
    8686    WEBCORE_EXPORT FontPlatformData(CTFontRef, float size, bool syntheticBold = false, bool syntheticOblique = false, FontOrientation = FontOrientation::Horizontal, FontWidthVariant = FontWidthVariant::RegularWidth, TextRenderingMode = TextRenderingMode::AutoTextRendering);
    8787#endif
     
    120120#endif
    121121
    122 #if PLATFORM(COCOA)
     122#if USE(CORE_TEXT)
    123123    CTFontRef font() const { return m_font.get(); }
    124124    WEBCORE_EXPORT CTFontRef registeredFont() const; // Returns nullptr iff the font is not registered, such as web fonts (otherwise returns font()).
     
    223223#endif
    224224
    225 #if PLATFORM(COCOA)
     225#if USE(CORE_TEXT)
    226226    // FIXME: Get rid of one of these. These two fonts are subtly different, and it is not obvious which one to use where.
    227227    RetainPtr<CTFontRef> m_font;
     
    277277};
    278278
    279 #if PLATFORM(COCOA)
     279#if USE(CORE_TEXT)
    280280bool isSystemFont(CTFontRef);
    281281#endif
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm

    r266688 r266936  
    2424#import "FontCascade.h"
    2525
    26 #import "ComplexTextController.h"
    27 #import "DashArray.h"
    28 #import "Font.h"
    29 #import "GlyphBuffer.h"
    3026#import "GraphicsContext.h"
    31 #import "LayoutRect.h"
    32 #import "Logging.h"
    3327#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>
    3928
    4029#if PLATFORM(IOS_FAMILY)
     
    5039namespace WebCore {
    5140
    52 // Confusingly, even when CGFontRenderingGetFontSmoothingDisabled() returns true, CGContextSetShouldSmoothFonts() still impacts text
    53 // 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 #else
    66     return false;
    67 #endif
    68 }
    69 
    7041bool FontCascade::canReturnFallbackFontsForComplexText()
    7142{
     
    7849}
    7950
    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)
     51void showLetterpressedGlyphsWithAdvances(const FloatPoint& point, const Font& font, GraphicsContext& coreContext, const CGGlyph* glyphs, const CGSize* advances, unsigned count)
    10252{
    10353#if ENABLE(LETTERPRESS)
     
    151101}
    152102
    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     }
    185103}
    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 #endif
    237 
    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             else
    256                 matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, -obliqueSkew, 0, 1, 0, 0));
    257         } else
    258             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     else
    300         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 #endif
    311 
    312     if (shouldAntialias != originalShouldAntialias)
    313         CGContextSetShouldAntialias(cgContext, originalShouldAntialias);
    314 }
    315 
    316 bool FontCascade::primaryFontIsSystemFont() const
    317 {
    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) const
    324 {
    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 #endif
    347         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  
    3636namespace WebCore {
    3737
    38 bool isSystemFont(CTFontRef font)
    39 {
    40 #if HAVE(CTFONTISSYSTEMUIFONT)
    41     return CTFontIsSystemUIFont(font);
    42 #else
    43     return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get());
    44 #endif
    45 }
    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 #endif
    63 }
    64 
    6538unsigned FontPlatformData::hash() const
    6639{
     
    7245        | m_syntheticOblique);
    7346
    74     uintptr_t fontHash = reinterpret_cast<uintptr_t>(CFHash(m_font.get()));
     47    uintptr_t fontHash = static_cast<uintptr_t>(CFHash(m_font.get()));
    7548    uintptr_t hashCodes[] = { fontHash, flags };
    7649    return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
     
    8457}
    8558
    86 CTFontRef FontPlatformData::registeredFont() const
    87 {
    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() const
    134 {
    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 fonts
    161     // 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() const
    168 {
    169     return objectForEqualityCheck(ctFont());
    170 }
    171 
    172 RefPtr<SharedBuffer> FontPlatformData::openTypeTable(uint32_t table) const
    173 {
    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_DISABLED
    181 
    182 String FontPlatformData::description() const
    183 {
    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 #endif
    192 
    193 String FontPlatformData::familyName() const
    194 {
    195     if (auto platformFont = font())
    196         return adoptCF(CTFontCopyFamilyName(platformFont)).get();
    197     return { };
    198 }
    199 
    20059} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp

    r265962 r266936  
    5353
    5454namespace WebCore {
    55 
    56 // FIXME: Remove this once kCMVideoCodecType_VP9 is added to CMFormatDescription.h
    57 constexpr CMVideoCodecType kCMVideoCodecType_VP9 { 'vp09' };
    5855
    5956using namespace PAL;
  • trunk/Source/WebCore/platform/graphics/ct/FontCascadeCoreText.cpp

    r266934 r266936  
    33 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2006-2011, 2016 Apple Inc.
     5 * Copyright (C) 2003, 2006-2020, 2016 Apple Inc.
    66 *
    77 * This library is free software; you can redistribute it and/or
     
    2121 */
    2222
    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>
    4840#endif
    4941
     
    5749    static bool subpixelAntialiasingEnabled;
    5850    static std::once_flag onceFlag;
    59     std::call_once(onceFlag, [&] () {
     51    std::call_once(onceFlag, [&]() {
    6052        subpixelAntialiasingEnabled = !CGFontRenderingGetFontSmoothingDisabled();
    6153    });
     
    6860}
    6961
    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)
     62void fillVectorWithHorizontalGlyphPositions(Vector<CGPoint, 256>& positions, CGContextRef context, const CGSize* advances, unsigned count)
    8163{
    8264    CGAffineTransform matrix = CGAffineTransformInvert(CGContextGetTextMatrix(context));
     
    9678    UNUSED_PARAM(context);
    9779    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)
    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 #endif
    135 
    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 #else
    144     UNUSED_PARAM(point);
    145     UNUSED_PARAM(font);
    146     UNUSED_PARAM(coreContext);
    147     UNUSED_PARAM(glyphs);
    148     UNUSED_PARAM(advances);
    149     UNUSED_PARAM(count);
    15080#endif
    15181}
     
    209139    bool shouldAntialias = true;
    210140    bool shouldSmoothFonts = true;
    211    
     141
    212142    if (!font.allowsAntialiasing())
    213143        smoothingMode = FontSmoothingMode::NoSmoothing;
     
    241171
    242172    bool useLetterpressEffect = shouldUseLetterpressEffect(context);
     173    UNUSED_VARIABLE(useLetterpressEffect);
    243174    FloatPoint point = anchorPoint;
    244175
     
    274205        float horizontalUnitLengthInDevicePixels = sqrtf(horizontalUnitSizeInDevicePixels.width() * horizontalUnitSizeInDevicePixels.width() + horizontalUnitSizeInDevicePixels.height() * horizontalUnitSizeInDevicePixels.height());
    275206        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.
    277208            syntheticBoldOffset = std::min(syntheticBoldOffset, syntheticBoldOffset / horizontalUnitLengthInDevicePixels);
    278209        }
     
    295226    }
    296227
     228#if ENABLE(LETTERPRESS)
    297229    if (useLetterpressEffect)
    298230        showLetterpressedGlyphsWithAdvances(point, font, context, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
    299231    else
     232#endif
     233    {
    300234        showGlyphsWithAdvances(point, font, cgContext, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs);
     235    }
     236
    301237    if (syntheticBoldOffset)
    302238        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  
    11/*
    2  * Copyright (C) 2005, 2006, 2010, 2011 Apple Inc. All rights reserved.
     2 * Copyright (C) 2005-2020 Apple Inc. All rights reserved.
    33 * Copyright (C) 2006 Alexey Proskuryakov
    44 *
     
    2525 */
    2626
    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>
    5650#endif
    5751
     
    144138#else
    145139    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();
    146147#endif
    147148
     
    247248    if (headTable && CFDataGetLength(headTable.get()) >= 42) {
    248249        const UInt8* head = CFDataGetBytePtr(headTable.get());
    249         ushort uxMin = head[36] * 256 + head[37];
    250         ushort uxMax = head[40] * 256 + head[41];
     250        unsigned uxMin = head[36] * 256 + head[37];
     251        unsigned uxMax = head[40] * 256 + head[41];
    251252        SInt16 xMin = static_cast<SInt16>(uxMin);
    252253        SInt16 xMax = static_cast<SInt16>(uxMax);
     
    257258    // Fallback to a cross-platform estimate, which will populate these values if they are non-positive.
    258259    initCharWidths();
    259 }
    260 
    261 void Font::platformDestroy()
    262 {
    263260}
    264261
     
    557554    float size = m_platformData.size() * scaleFactor;
    558555    CTFontSymbolicTraits fontTraits = CTFontGetSymbolicTraits(m_platformData.font());
    559     auto fontDescriptor = adoptCF(CTFontCopyFontDescriptor(m_platformData.font()));
     556    RetainPtr<CTFontDescriptorRef> fontDescriptor = adoptCF(CTFontCopyFontDescriptor(m_platformData.font()));
    560557    RetainPtr<CTFontRef> scaledFont = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), size, nullptr));
    561558
     
    569566    // FIXME: Implement GlyphBuffer initial advance.
    570567#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    {
    572570        range.location = std::min(std::max(range.location, static_cast<CFIndex>(0)), static_cast<CFIndex>(glyphBuffer.size()));
    573571        if (range.length < 0) {
  • trunk/Source/WebCore/platform/graphics/ct/FontPlatformDataCoreText.cpp

    r266934 r266936  
    22 * This file is part of the internal font implementation.
    33 *
    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.
    65 *
    76 * This library is free software; you can redistribute it and/or
     
    2221 */
    2322
    24 #import "config.h"
    25 #import "FontPlatformData.h"
     23#include "config.h"
     24#include "FontPlatformData.h"
    2625
    27 #import "SharedBuffer.h"
    28 #import <pal/spi/cocoa/CoreTextSPI.h>
    29 #import <wtf/text/StringConcatenateNumbers.h>
     26#include "SharedBuffer.h"
     27#include <CoreText/CoreText.h>
     28#include <wtf/text/StringConcatenateNumbers.h>
    3029
    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>
    3434#endif
    3535
    3636namespace WebCore {
    37 
    38 bool isSystemFont(CTFontRef font)
    39 {
    40 #if HAVE(CTFONTISSYSTEMUIFONT)
    41     return CTFontIsSystemUIFont(font);
    42 #else
    43     return CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(font)).get());
    44 #endif
    45 }
    46 
    47 // These CoreText Text Spacing feature selectors are not defined in CoreText.
    48 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidth, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth };
    4937
    5038FontPlatformData::FontPlatformData(CTFontRef font, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode)
     
    5341    ASSERT_ARG(font, font);
    5442    m_font = font;
    55     m_isColorBitmapFont = CTFontGetSymbolicTraits(font) & kCTFontTraitColorGlyphs;
     43    m_isColorBitmapFont = CTFontGetSymbolicTraits(font) & kCTFontColorGlyphsTrait;
    5644    m_isSystemFont = WebCore::isSystemFont(m_font.get());
    5745    auto variations = adoptCF(static_cast<CFDictionaryRef>(CTFontCopyAttribute(font, kCTFontVariationAttribute)));
     
    6351}
    6452
    65 unsigned FontPlatformData::hash() const
     53bool isSystemFont(CTFontRef font)
    6654{
    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
    8460}
    8561
     
    9369}
    9470
     71#if PLATFORM(COCOA)
    9572inline int mapFontWidthVariantToCTFeatureSelector(FontWidthVariant variant)
    9673{
    97     switch(variant) {
     74    switch (variant) {
    9875    case FontWidthVariant::RegularWidth:
    99         return TextSpacingProportional;
     76        return kProportionalTextSelector;
    10077
    10178    case FontWidthVariant::HalfWidth:
    102         return TextSpacingHalfWidth;
     79        return kHalfWidthTextSelector;
    10380
    10481    case FontWidthVariant::ThirdWidth:
    105         return TextSpacingThirdWidth;
     82        return kThirdWidthTextSelector;
    10683
    10784    case FontWidthVariant::QuarterWidth:
    108         return TextSpacingQuarterWidth;
     85        return kQuarterWidthTextSelector;
    10986    }
    11087
    11188    ASSERT_NOT_REACHED();
    112     return TextSpacingProportional;
     89    return kProportionalTextSelector;
    11390}
    11491
     
    154131    return m_ctFont.get();
    155132}
     133#else
     134CTFontRef FontPlatformData::ctFont() const
     135{
     136    return font();
     137}
     138#endif
    156139
    157140RetainPtr<CFTypeRef> FontPlatformData::objectForEqualityCheck(CTFontRef ctFont)
     
    174157    if (RetainPtr<CFDataRef> data = adoptCF(CTFontCopyTable(font(), table, kCTFontTableOptionNoOptions)))
    175158        return SharedBuffer::create(data.get());
    176    
     159
    177160    return nullptr;
    178161}
  • trunk/Source/WebCore/platform/graphics/ct/GlyphPageCoreText.cpp

    r266934 r266936  
    11/*
    2  * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    77 *
    88 * 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.
    1010 * 2.  Redistributions in binary form must reproduce the above copyright
    1111 *     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.
    1313 * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
    1414 *     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.
    1616 *
    1717 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
     
    3333#include "FontCascade.h"
    3434#include <pal/spi/cg/CoreGraphicsSPI.h>
     35
     36#if PLATFORM(COCOA)
    3537#include <pal/spi/cocoa/CoreTextSPI.h>
     38#else
     39#include <pal/spi/win/CoreTextSPIWin.h>
     40#endif
    3641
    3742namespace WebCore {
Note: See TracChangeset for help on using the changeset viewer.