haikuwebkit/LayoutTests/fast/canvas/fill-text-with-font-feature...

34 lines
871 B
HTML
Raw Permalink Normal View History

[GPU Process] Support drawing text in 2D canvas with font features https://bugs.webkit.org/show_bug.cgi?id=206118 Reviewed by Wenson Hsieh. Source/WebCore: This patch simply serializes all the non-derived data in Font and FontPlatformData. Serializing a CTFont involves serializing its font descriptor's attributes. However, there's an extra step for web fonts, since the font descriptor's attributes don't include the raw bytes of the font file. This was previously being saved in Font, but this patch moves that into FontPlatformData because of layering, and adds the SharedBuffer to the serialization routine for web fonts. Test: fast/canvas/fill-text-with-font-features.html * WebCore.xcodeproj/project.pbxproj: * css/CSSFontFace.cpp: (WebCore::CSSFontFace::font): Fonts and FontPlatformDatas are supposed to be immutable, so having a setter for the FontFaceData is incorrect. This object is moved into the constructor instead. * css/CSSFontFaceSource.cpp: (WebCore::CSSFontFaceSource::font): Deleting dead code. * platform/graphics/Font.cpp: (WebCore::Font::setFontFaceData): Deleted. * platform/graphics/Font.h: (WebCore::Font::fontFaceData const): Deleted. Moved to FontPlatformData * platform/graphics/FontPlatformData.cpp: (WebCore::FontPlatformData::FontPlatformData): * platform/graphics/FontPlatformData.h: (WebCore::FontPlatformData::creationData const): Moved from Font. * platform/graphics/coretext/FontPlatformDataCoreText.cpp: (WebCore::FontPlatformData::FontPlatformData): * platform/graphics/mac/FontCustomPlatformData.cpp: (WebCore::FontCustomPlatformData::fontPlatformData): FontCustomPlatformData is a struct, so there's no need for the m_ prefixes. (WebCore::createFontCustomPlatformData): * platform/graphics/mac/FontCustomPlatformData.h: (WebCore::FontCustomPlatformData::FontCustomPlatformData): Ditto. Source/WebKit: Simply serialize and deserialize all the non-derived data in Font and PlatformFontData. * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: (IPC::ArgumentCoder<Ref<Font>>::encodePlatformData): (IPC::ArgumentCoder<Ref<Font>>::decodePlatformData): * Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<Ref<Font>>::encode): (IPC::ArgumentCoder<Ref<Font>>::decode): * Shared/WebCoreArgumentCoders.h: LayoutTests: * fast/canvas/fill-text-with-font-features-expected.html: Added. * fast/canvas/fill-text-with-font-features.html: Added. * fast/canvas/resources/FontWithFeatures.ttf: Added. Canonical link: https://commits.webkit.org/230041@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-03 17:31:30 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
@font-face {
font-family: "SpecialFont";
src: url("resources/FontWithFeatures.ttf") format("truetype");
}
</style>
</head>
<body>
<p>You should see a row of 3 check marks followed by a row of 3 crosses below.</p>
<canvas width="400" height="400"></canvas>
<script>
if (window.testRunner)
testRunner.waitUntilDone();
addEventListener("load", async function() {
document.fonts.load("80px SpecialFont").then(function() {
const context = document.querySelector("canvas").getContext("2d");
context.font = "80px SpecialFont";
context.fillText("AAA", 100, 100);
context.fillText("BBB", 100, 200);
if (window.testRunner)
testRunner.notifyDone();
}, function() {
if (window.testRunner)
testRunner.notifyDone();
});
});
</script>
</body>
</html>