Diff
Modified: trunk/ChangeLog (266981 => 266982)
--- trunk/ChangeLog 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/ChangeLog 2020-09-12 23:01:36 UTC (rev 266982)
@@ -1,3 +1,14 @@
+2020-09-12 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [Apple Win] Add a CTFont member to FontPlatformData
+ https://bugs.webkit.org/show_bug.cgi?id=216432
+
+ Reviewed by Darin Adler.
+
+ Include ***CoreText.cpp files on the Apple Win port.
+
+ * Source/cmake/OptionsAppleWin.cmake:
+
2020-09-10 Adrian Perez de Castro <ape...@igalia.com>
[CMake] Use imported targets in find module for libseccomp
Modified: trunk/Source/WebCore/ChangeLog (266981 => 266982)
--- trunk/Source/WebCore/ChangeLog 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/ChangeLog 2020-09-12 23:01:36 UTC (rev 266982)
@@ -1,5 +1,42 @@
2020-09-12 Myles C. Maxfield <mmaxfi...@apple.com>
+ [Apple Win] Add a CTFont member to FontPlatformData
+ https://bugs.webkit.org/show_bug.cgi?id=216432
+
+ Reviewed by Darin Adler.
+
+ This is the second step on the path to replacing the Apple Win port's use of CGFont with CTFont.
+ This patch adds m_ctFont to FontPlatformData, and makes FontPlatformData's constructors create
+ this object from their existing arguments. It also enables the USE(CORE_TEXT) flag on the Apple
+ Win port, but manually disables each of the USE(CORE_TEXT) sites on Windows, so there isn't any
+ behavior change just yet. The new member, m_ctFont, is therefore still unused in this patch. The
+ next steps will be replacing our current Apple Win font functions with their USE(CORE_TEXT)
+ counterparts, one-by-one. (Replacing them one-by-one is better than doing them all at once in a
+ giant mondo-patch.)
+
+ No new tests because there is no behavior change yet.
+
+ * PlatformAppleWin.cmake:
+ * platform/graphics/Font.cpp:
+ * platform/graphics/FontCascade.cpp:
+ * platform/graphics/FontPlatformData.cpp:
+ * platform/graphics/FontPlatformData.h: The #defines are temporarily getting worse before they'll
+ be getting better. When this project is done, there will be fewer #defines, and this file will be
+ cleaner than it was when I started.
+ (WebCore::FontPlatformData::cgFont const):
+ (WebCore::FontPlatformData::ctFont const):
+ * platform/graphics/coretext/FontCascadeCoreText.cpp:
+ * platform/graphics/coretext/FontCoreText.cpp:
+ * platform/graphics/coretext/FontPlatformDataCoreText.cpp:
+ * platform/graphics/coretext/GlyphPageCoreText.cpp:
+ * platform/graphics/win/FontPlatformDataCGWin.cpp:
+ (WebCore::FontPlatformData::platformDataInit):
+ (WebCore::FontPlatformData::FontPlatformData):
+ (WebCore::FontPlatformData::hash const):
+ (WebCore::FontPlatformData::platformIsEqual const):
+
+2020-09-12 Myles C. Maxfield <mmaxfi...@apple.com>
+
Remove dead code FontCascadeCGWin.cpp
https://bugs.webkit.org/show_bug.cgi?id=216444
Modified: trunk/Source/WebCore/PlatformAppleWin.cmake (266981 => 266982)
--- trunk/Source/WebCore/PlatformAppleWin.cmake 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/PlatformAppleWin.cmake 2020-09-12 23:01:36 UTC (rev 266982)
@@ -150,6 +150,11 @@
platform/graphics/cg/TransformationMatrixCG.cpp
platform/graphics/cg/UTIRegistry.cpp
+ platform/graphics/coretext/FontCascadeCoreText.cpp
+ platform/graphics/coretext/FontCoreText.cpp
+ platform/graphics/coretext/FontPlatformDataCoreText.cpp
+ platform/graphics/coretext/GlyphPageCoreText.cpp
+
platform/graphics/opentype/OpenTypeCG.cpp
platform/graphics/win/FontCGWin.cpp
Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (266981 => 266982)
--- trunk/Source/WebCore/platform/graphics/Font.cpp 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp 2020-09-12 23:01:36 UTC (rev 266982)
@@ -474,7 +474,7 @@
return *derivedFontData.brokenIdeographFont;
}
-#if !USE(CORE_TEXT)
+#if !USE(CORE_TEXT) || PLATFORM(WIN)
bool Font::isProbablyOnlyUsedToRenderIcons() const
{
@@ -511,7 +511,7 @@
return platformCreateScaledFont(fontDescription, scaleFactor);
}
-#if !USE(CORE_TEXT)
+#if !USE(CORE_TEXT) || PLATFORM(WIN)
void Font::applyTransforms(GlyphBuffer&, unsigned, unsigned, bool, bool, const AtomString&, StringView, TextDirection) const
{
}
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (266981 => 266982)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-09-12 23:01:36 UTC (rev 266982)
@@ -595,7 +595,7 @@
return shouldUseFontSmoothing;
}
-#if !USE(CORE_TEXT)
+#if !USE(CORE_TEXT) || PLATFORM(WIN)
bool FontCascade::isSubpixelAntialiasingAvailable()
{
return false;
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp (266981 => 266982)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.cpp 2020-09-12 23:01:36 UTC (rev 266982)
@@ -31,6 +31,10 @@
#include <CoreGraphics/CGFont.h>
#endif
+#if PLATFORM(WIN) && USE(CORE_TEXT)
+#include <pal/spi/win/CoreTextSPIWin.h>
+#endif
+
namespace WebCore {
FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
@@ -52,15 +56,6 @@
{
}
-#if USE(CG) && PLATFORM(WIN)
-FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode)
- : FontPlatformData(size, syntheticBold, syntheticOblique, orientation, widthVariant, textRenderingMode)
-{
- m_cgFont = cgFont;
- ASSERT(m_cgFont);
-}
-#endif
-
#if !USE(FREETYPE)
FontPlatformData FontPlatformData::cloneWithOrientation(const FontPlatformData& source, FontOrientation orientation)
{
@@ -84,7 +79,7 @@
}
#endif
-#if !USE(CORE_TEXT)
+#if !USE(CORE_TEXT) || PLATFORM(WIN)
String FontPlatformData::familyName() const
{
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (266981 => 266982)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2020-09-12 23:01:36 UTC (rev 266982)
@@ -86,40 +86,38 @@
WEBCORE_EXPORT FontPlatformData(CTFontRef, float size, bool syntheticBold = false, bool syntheticOblique = false, FontOrientation = FontOrientation::Horizontal, FontWidthVariant = FontWidthVariant::RegularWidth, TextRenderingMode = TextRenderingMode::AutoTextRendering);
#endif
- static FontPlatformData cloneWithOrientation(const FontPlatformData&, FontOrientation);
- static FontPlatformData cloneWithSyntheticOblique(const FontPlatformData&, bool);
- static FontPlatformData cloneWithSize(const FontPlatformData&, float);
-
-#if USE(CG) && PLATFORM(WIN)
- FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOblique, FontOrientation, FontWidthVariant, TextRenderingMode);
-#endif
-
#if PLATFORM(WIN)
FontPlatformData(GDIObject<HFONT>, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
-#endif
-
-#if PLATFORM(WIN) && USE(CG)
+#if USE(CG)
FontPlatformData(GDIObject<HFONT>, CGFontRef, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
+ FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOblique, FontOrientation, FontWidthVariant, TextRenderingMode);
#endif
-
-#if PLATFORM(WIN) && USE(DIRECT2D)
+#if USE(DIRECT2D)
FontPlatformData(GDIObject<HFONT>&&, COMPtr<IDWriteFont>&&, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
#endif
-
-#if PLATFORM(WIN) && USE(CAIRO)
+#if USE(CAIRO)
FontPlatformData(GDIObject<HFONT>, cairo_font_face_t*, float size, bool bold, bool italic);
#endif
+#endif
#if USE(FREETYPE)
FontPlatformData(cairo_font_face_t*, RefPtr<FcPattern>&&, float size, bool fixedWidth, bool syntheticBold, bool syntheticOblique, FontOrientation);
#endif
+ static FontPlatformData cloneWithOrientation(const FontPlatformData&, FontOrientation);
+ static FontPlatformData cloneWithSyntheticOblique(const FontPlatformData&, bool);
+ static FontPlatformData cloneWithSize(const FontPlatformData&, float);
+
#if PLATFORM(WIN)
HFONT hfont() const { return m_font ? m_font->get() : 0; }
bool useGDI() const { return m_useGDI; }
+#if USE(CG)
+ CGFontRef cgFont() const { return m_cgFont.get(); }
#endif
-
#if USE(CORE_TEXT)
+ CTFontRef ctFont() const { return m_ctFont.get(); }
+#endif
+#elif USE(CORE_TEXT)
CTFontRef font() const { return m_font.get(); }
WEBCORE_EXPORT CTFontRef registeredFont() const; // Returns nullptr iff the font is not registered, such as web fonts (otherwise returns font()).
@@ -136,10 +134,6 @@
bool hasVariations() const { return m_hasVariations; }
-#if USE(CG) && PLATFORM(WIN)
- CGFontRef cgFont() const { return m_cgFont.get(); }
-#endif
-
#if USE(DIRECT2D)
IDWriteFont* dwFont() const { return m_dwFont.get(); }
IDWriteFontFace* dwFontFace() const { return m_dwFontFace.get(); }
@@ -199,13 +193,9 @@
#endif
}
-#if PLATFORM(COCOA) || PLATFORM(WIN) || USE(FREETYPE)
RefPtr<SharedBuffer> openTypeTable(uint32_t table) const;
-#endif
-#if !LOG_DISABLED
String description() const;
-#endif
private:
bool platformIsEqual(const FontPlatformData&) const;
@@ -222,18 +212,20 @@
void buildScaledFont(cairo_font_face_t*);
#endif
+#if PLATFORM(WIN)
+ RefPtr<SharedGDIObject<HFONT>> m_font; // FIXME: Delete this in favor of m_ctFont or m_dwFont or m_scaledFont.
+#if USE(CG)
+ RetainPtr<CGFontRef> m_cgFont; // FIXME: Delete this in favor of m_ctFont.
+#endif
#if USE(CORE_TEXT)
+ RetainPtr<CTFontRef> m_ctFont;
+#endif
+#elif USE(CORE_TEXT)
// FIXME: Get rid of one of these. These two fonts are subtly different, and it is not obvious which one to use where.
RetainPtr<CTFontRef> m_font;
mutable RetainPtr<CTFontRef> m_ctFont;
-#elif PLATFORM(WIN)
- RefPtr<SharedGDIObject<HFONT>> m_font;
#endif
-#if USE(CG) && PLATFORM(WIN)
- RetainPtr<CGFontRef> m_cgFont;
-#endif
-
#if USE(DIRECT2D)
COMPtr<IDWriteFont> m_dwFont;
COMPtr<IDWriteFontFace> m_dwFontFace;
@@ -247,8 +239,6 @@
RefPtr<FcPattern> m_pattern;
#endif
- // The values below are common to all ports
- // FIXME: If they're common to all ports, they should move to Font
float m_size { 0 };
FontOrientation m_orientation { FontOrientation::Horizontal };
Modified: trunk/Source/WebCore/platform/graphics/coretext/FontCascadeCoreText.cpp (266981 => 266982)
--- trunk/Source/WebCore/platform/graphics/coretext/FontCascadeCoreText.cpp 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/platform/graphics/coretext/FontCascadeCoreText.cpp 2020-09-12 23:01:36 UTC (rev 266982)
@@ -41,6 +41,8 @@
namespace WebCore {
+#if !PLATFORM(WIN)
+
// Confusingly, even when CGFontRenderingGetFontSmoothingDisabled() returns true, CGContextSetShouldSmoothFonts() still impacts text
// rendering, which is why this function uses the "subpixel antialiasing" rather than "smoothing" terminology.
bool FontCascade::isSubpixelAntialiasingAvailable()
@@ -309,4 +311,6 @@
return Font::systemFallback();
}
+#endif
+
}
Modified: trunk/Source/WebCore/platform/graphics/coretext/FontCoreText.cpp (266981 => 266982)
--- trunk/Source/WebCore/platform/graphics/coretext/FontCoreText.cpp 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/platform/graphics/coretext/FontCoreText.cpp 2020-09-12 23:01:36 UTC (rev 266982)
@@ -51,6 +51,8 @@
namespace WebCore {
+#if !PLATFORM(WIN)
+
static inline bool caseInsensitiveCompare(CFStringRef a, CFStringRef b)
{
return a && CFStringCompare(a, b, kCFCompareCaseInsensitive) == kCFCompareEqualTo;
@@ -768,4 +770,6 @@
});
}
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/coretext/FontPlatformDataCoreText.cpp (266981 => 266982)
--- trunk/Source/WebCore/platform/graphics/coretext/FontPlatformDataCoreText.cpp 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/platform/graphics/coretext/FontPlatformDataCoreText.cpp 2020-09-12 23:01:36 UTC (rev 266982)
@@ -35,6 +35,8 @@
namespace WebCore {
+#if !PLATFORM(WIN)
+
FontPlatformData::FontPlatformData(CTFontRef font, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode)
: FontPlatformData(size, syntheticBold, syntheticOblique, orientation, widthVariant, textRenderingMode)
{
@@ -180,4 +182,6 @@
return { };
}
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/coretext/GlyphPageCoreText.cpp (266981 => 266982)
--- trunk/Source/WebCore/platform/graphics/coretext/GlyphPageCoreText.cpp 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/platform/graphics/coretext/GlyphPageCoreText.cpp 2020-09-12 23:01:36 UTC (rev 266982)
@@ -41,6 +41,8 @@
namespace WebCore {
+#if !PLATFORM(WIN)
+
static bool shouldFillWithVerticalGlyphs(const UChar* buffer, unsigned bufferLength, const Font& font)
{
if (!font.hasVerticalGlyphs())
@@ -78,4 +80,6 @@
return haveGlyphs;
}
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp (266981 => 266982)
--- trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp 2020-09-12 23:01:36 UTC (rev 266982)
@@ -28,6 +28,7 @@
#include "SharedGDIObject.h"
#include <pal/spi/cg/CoreGraphicsSPI.h>
+#include <pal/spi/win/CoreTextSPIWin.h>
#include <wtf/HashMap.h>
#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
@@ -114,6 +115,7 @@
LOGFONT logfont;
GetObject(font, sizeof(logfont), &logfont);
m_cgFont = adoptCF(CGFontCreateWithPlatformFont(&logfont));
+ m_ctFont = adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), size, nullptr, nullptr));
if (!m_useGDI)
m_isSystemFont = !wcscmp(faceName, L"Lucida Grande");
}
@@ -124,19 +126,33 @@
, m_size(size)
, m_font(SharedGDIObject<HFONT>::create(WTFMove(hfont)))
, m_cgFont(font)
+ , m_ctFont(adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), size, nullptr, nullptr)))
, m_useGDI(useGDI)
{
}
+FontPlatformData::FontPlatformData(CGFontRef cgFont, float size, bool syntheticBold, bool syntheticOblique, FontOrientation orientation, FontWidthVariant widthVariant, TextRenderingMode textRenderingMode)
+ : FontPlatformData(size, syntheticBold, syntheticOblique, orientation, widthVariant, textRenderingMode)
+{
+ m_cgFont = cgFont;
+ ASSERT(m_cgFont);
+ m_ctFont = adoptCF(CTFontCreateWithGraphicsFont(m_cgFont.get(), size, nullptr, nullptr));
+}
+
unsigned FontPlatformData::hash() const
{
- return m_font ? m_font->hash() : 0;
+ unsigned fontHash = m_font ? m_font->hash() : 0;
+ CFHashCode cgFontHash = WTF::safeCFHash(m_cgFont.get());
+ CFHashCode ctFontHash = WTF::safeCFHash(m_ctFont.get());
+ uintptr_t hashCodes[] = { fontHash, cgFontHash, ctFontHash, m_useGDI };
+ return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
}
bool FontPlatformData::platformIsEqual(const FontPlatformData& other) const
{
return m_font == other.m_font
- && m_cgFont == other.m_cgFont
+ && WTF::safeCFEqual(m_cgFont.get(), other.m_cgFont.get())
+ && WTF::safeCFEqual(m_ctFont.get(), other.m_ctFont.get())
&& m_useGDI == other.m_useGDI;
}
Modified: trunk/Source/cmake/OptionsAppleWin.cmake (266981 => 266982)
--- trunk/Source/cmake/OptionsAppleWin.cmake 2020-09-12 22:10:20 UTC (rev 266981)
+++ trunk/Source/cmake/OptionsAppleWin.cmake 2020-09-12 23:01:36 UTC (rev 266982)
@@ -48,6 +48,7 @@
else ()
SET_AND_EXPOSE_TO_BUILD(USE_CA ON)
SET_AND_EXPOSE_TO_BUILD(USE_CG ON)
+ SET_AND_EXPOSE_TO_BUILD(USE_CORE_TEXT ON)
set(CMAKE_REQUIRED_INCLUDES ${WEBKIT_LIBRARIES_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES