commit 1a082c6d0805d634c02c5b2bbddbc5a32db13276 Author: Pierre Rossi Date: Tue Apr 9 18:12:54 2013 +0200 [Qt] Add WOFF support when using zlib https://bugs.webkit.org/show_bug.cgi?id=112805 http://trac.webkit.org/r147020 Reviewed by Allan Sandfeld Jensen. Covered by existing test: fast/css/font-face-woff.html * Target.pri: Conditional inclusion of WOFFFileFormat * platform/graphics/qt/FontCustomPlatformDataQt.cpp: (WebCore::createFontCustomPlatformData): Try to unpack WOFF data, otherwise spit out a warning and bail. (WebCore::FontCustomPlatformData::supportsFormat): accept WOFF webfonts if USE(ZLIB). Change-Id: I003cdffa3dcd3eb022ae47db30fdd65ebff3952b Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Simon Hausmann diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri index 1f41c85..16915a4 100644 --- a/Source/WebCore/Target.pri +++ b/Source/WebCore/Target.pri @@ -4043,6 +4043,11 @@ use?(WEBP) { SOURCES += platform/image-decoders/webp/WEBPImageDecoder.cpp } +use?(ZLIB) { + HEADERS += platform/graphics/WOFFFileFormat.h + SOURCES += platform/graphics/WOFFFileFormat.cpp +} + !have?(sqlite3):exists($${SQLITE3SRCDIR}/sqlite3.c) { # Build sqlite3 into WebCore from source # somewhat copied from $$QT_SOURCE_TREE/src/plugins/sqldrivers/sqlite/sqlite.pro diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp index 2be3855..5c36380 100644 --- a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp +++ b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp @@ -24,6 +24,9 @@ #include "FontPlatformData.h" #include "SharedBuffer.h" +#if USE(ZLIB) +#include "WOFFFileFormat.h" +#endif #include namespace WebCore { @@ -39,7 +42,25 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) { ASSERT_ARG(buffer, buffer); +#if USE(ZLIB) + RefPtr sfntBuffer; + if (isWOFF(buffer)) { + Vector sfnt; + if (!convertWOFFToSfnt(buffer, sfnt)) + return 0; + + sfntBuffer = SharedBuffer::adoptVector(sfnt); + buffer = sfntBuffer.get(); + } +#endif // USE(ZLIB) + const QByteArray fontData(buffer->data(), buffer->size()); +#if !USE(ZLIB) + if (fontData.startsWith("wOFF")) { + qWarning("WOFF support requires QtWebKit to be built with zlib support."); + return 0; + } +#endif // !USE(ZLIB) // Pixel size doesn't matter at this point, it is set in FontCustomPlatformData::fontPlatformData. QRawFont rawFont(fontData, /*pixelSize = */0, QFont::PreferDefaultHinting); if (!rawFont.isValid()) @@ -52,7 +73,11 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) bool FontCustomPlatformData::supportsFormat(const String& format) { - return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype"); + return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype") +#if USE(ZLIB) + || equalIgnoringCase(format, "woff") +#endif + ; } }