diff options
author | Pierre Rossi <pierre.rossi@digia.com> | 2013-04-09 18:12:54 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-11 13:09:26 +0200 |
commit | 1a082c6d0805d634c02c5b2bbddbc5a32db13276 (patch) | |
tree | aa4c5e669206f17f2f7bf9eec509e65453007cd1 /Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp | |
parent | 57992527bde37706ebfc4ed4940bc20a0784eb0c (diff) |
[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 <allan.jensen@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp b/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp index 2be38550e..5c36380d2 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 <QStringList> namespace WebCore { @@ -39,7 +42,25 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer) { ASSERT_ARG(buffer, buffer); +#if USE(ZLIB) + RefPtr<SharedBuffer> sfntBuffer; + if (isWOFF(buffer)) { + Vector<char> 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 + ; } } |