Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit 04b74f9

Browse files
vitalliumariya
authored andcommitted
Enable WOFF file support.
Background: WOFF format requires that WebKit should be compiled with zlib. Related issues: http://code.google.com/p/phantomjs/issues/detail?id=592
1 parent eb3c9ca commit 04b74f9

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

src/qt/preconfig.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set QT_CFG=%QT_CFG% -no-declarative
1818
set QT_CFG=%QT_CFG% -no-script
1919
set QT_CFG=%QT_CFG% -no-multimedia
2020

21+
set QT_CFG=%QT_CFG% -qt-zlib
2122
set QT_CFG=%QT_CFG% -qt-libpng
2223
set QT_CFG=%QT_CFG% -qt-libjpeg
2324
set QT_CFG=%QT_CFG% -no-libmng

src/qt/src/3rdparty/webkit/Source/WebCore/WebCore.pri

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ contains(DEFINES, ENABLE_XSLT=1) {
170170
QT *= xmlpatterns
171171
}
172172

173+
contains(DEFINES, ENABLE_ZLIB=1) {
174+
include($$QT_SOURCE_TREE/src/3rdparty/zlib_dependency.pri)
175+
}
176+
173177
contains(DEFINES, ENABLE_SQLITE=1) {
174178
!system-sqlite:exists( $${SQLITE3SRCDIR}/sqlite3.c ) {
175179
INCLUDEPATH += $${SQLITE3SRCDIR}

src/qt/src/3rdparty/webkit/Source/WebCore/WebCore.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ SOURCES += \
988988
platform/graphics/PathTraversalState.cpp \
989989
platform/graphics/Pattern.cpp \
990990
platform/graphics/RoundedIntRect.cpp \
991+
platform/graphics/WOFFFileFormat.cpp \
991992
platform/graphics/SegmentedFontData.cpp \
992993
platform/graphics/ShadowBlur.cpp \
993994
platform/graphics/SVGGlyph.cpp \
@@ -1958,6 +1959,7 @@ HEADERS += \
19581959
platform/graphics/PathTraversalState.h \
19591960
platform/graphics/Pattern.h \
19601961
platform/graphics/RoundedIntRect.h \
1962+
platform/graphics/WOFFFileFormat.h \
19611963
platform/graphics/qt/FontCustomPlatformData.h \
19621964
platform/graphics/qt/ImageDecoderQt.h \
19631965
platform/graphics/qt/StillImageQt.h \

src/qt/src/3rdparty/webkit/Source/WebCore/features.pri

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) {
4545
!contains(DEFINES, ENABLE_DIRECTORY_UPLOAD=.): DEFINES += ENABLE_DIRECTORY_UPLOAD=0
4646
!contains(DEFINES, ENABLE_FILE_SYSTEM=.): DEFINES += ENABLE_FILE_SYSTEM=0
4747
!contains(DEFINES, ENABLE_QUOTA=.): DEFINES += ENABLE_QUOTA=0
48+
# enable zlib support for WOFF fonts
49+
!contains(DEFINES, ENABLE_ZLIB=.): DEFINES += ENABLE_ZLIB=1
4850

4951
# turn on SQLITE support if any of the dependent features are turned on
5052
!contains(DEFINES, ENABLE_SQLITE=.) {

src/qt/src/3rdparty/webkit/Source/WebCore/platform/graphics/qt/FontCustomPlatformDataQt.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "FontPlatformData.h"
2626
#include "SharedBuffer.h"
27+
#include "WOFFFileFormat.h"
2728
#include <QFontDatabase>
2829
#include <QStringList>
2930

@@ -50,6 +51,15 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
5051
{
5152
ASSERT_ARG(buffer, buffer);
5253

54+
RefPtr<SharedBuffer> sfntBuffer;
55+
if (isWOFF(buffer)) {
56+
Vector<char> sfnt;
57+
if (!convertWOFFToSfnt(buffer, sfnt))
58+
return 0;
59+
sfntBuffer = SharedBuffer::adoptVector(sfnt);
60+
buffer = sfntBuffer.get();
61+
}
62+
5363
int id = QFontDatabase::addApplicationFontFromData(QByteArray(buffer->data(), buffer->size()));
5464
if (id == -1)
5565
return 0;
@@ -63,7 +73,7 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
6373

6474
bool FontCustomPlatformData::supportsFormat(const String& format)
6575
{
66-
return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype");
76+
return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "opentype") || equalIgnoringCase(format, "woff");
6777
}
6878

6979
}

0 commit comments

Comments
 (0)