Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit 612bea95ea8a0bb09046d9d7c459e6fec8bc5e54
- Author: Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
- Date: Mon Dec 14 16:37:48 2009 +0100
- Make the Qt DRT use a fixed set of SVG fonts for all text rendering
- Reviewed by Simon Hausmann.
- On startup we load a set of SVG fonts for the generic font families
- and instruct the DRT to use only these fonts, even when asked for
- families where there's a system font available.
- Hopefully this should give us cross-platform DRT results between Mac,
- Linux and Windows, and possibly other platforms, without variations in
- font metrics based on the underlying font engines on each platform.
- WebCore:
- * platform/graphics/qt/FontCacheQt.cpp:
- WebKit/qt:
- * QtLauncher/QtLauncher.pro:
- * QtLauncher/main.cpp:
- WebKitTools:
- * DumpRenderTree/qt/DumpRenderTree.cpp:
- * DumpRenderTree/qt/DumpRenderTree.h:
- * DumpRenderTree/qt/main.cpp:
- * Scripts/run-webkit-tests:
- diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
- index 8f380a8..e61473c 100644
- --- a/WebCore/ChangeLog
- +++ b/WebCore/ChangeLog
- @@ -1,3 +1,19 @@
- +2009-12-14 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
- +
- + Reviewed by Simon Hausmann.
- +
- + Make the Qt DRT use a fixed set of SVG fonts for all text rendering
- +
- + On startup we load a set of SVG fonts for the generic font families
- + and instruct the DRT to use only these fonts, even when asked for
- + families where there's a system font available.
- +
- + Hopefully this should give us cross-platform DRT results between Mac,
- + Linux and Windows, and possibly other platforms, without variations in
- + font metrics based on the underlying font engines on each platform.
- +
- + * platform/graphics/qt/FontCacheQt.cpp:
- +
- 2009-12-07 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
- Reviewed by Simon Hausmann.
- diff --git a/WebCore/platform/graphics/qt/FontCacheQt.cpp b/WebCore/platform/graphics/qt/FontCacheQt.cpp
- index 82fb709..2f393c2 100644
- --- a/WebCore/platform/graphics/qt/FontCacheQt.cpp
- +++ b/WebCore/platform/graphics/qt/FontCacheQt.cpp
- @@ -35,6 +35,7 @@
- #include <wtf/StdLibExtras.h>
- #include <QFont>
- +#include "qwebpage_p.h"
- using namespace WTF;
- @@ -66,6 +67,9 @@ void FontCache::getTraitsInFamily(const AtomicString&, Vector<unsigned>&)
- FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName)
- {
- + if (QWebPagePrivate::drtRun)
- + return 0; // TODO: Special-case loading of DRT-specific fonts such as Ahem.ttf
- +
- return new FontPlatformData(fontDescription, familyName);
- }
- diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
- index 9ef13f1..5372ba4 100644
- --- a/WebKit/qt/ChangeLog
- +++ b/WebKit/qt/ChangeLog
- @@ -1,3 +1,20 @@
- +2009-12-14 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
- +
- + Reviewed by Simon Hausmann.
- +
- + Make the Qt DRT use a fixed set of SVG fonts for all text rendering
- +
- + On startup we load a set of SVG fonts for the generic font families
- + and instruct the DRT to use only these fonts, even when asked for
- + families where there's a system font available.
- +
- + Hopefully this should give us cross-platform DRT results between Mac,
- + Linux and Windows, and possibly other platforms, without variations in
- + font metrics based on the underlying font engines on each platform.
- +
- + * QtLauncher/QtLauncher.pro:
- + * QtLauncher/main.cpp:
- +
- 2009-12-04 Jocelyn Turcotte <jocelyn.turcotte@nokia.com>
- Reviewed by Kenneth Rohde Christiansen.
- diff --git a/WebKit/qt/QtLauncher/QtLauncher.pro b/WebKit/qt/QtLauncher/QtLauncher.pro
- index 133869c..b71c5a9 100644
- --- a/WebKit/qt/QtLauncher/QtLauncher.pro
- +++ b/WebKit/qt/QtLauncher/QtLauncher.pro
- @@ -6,6 +6,9 @@ DESTDIR = ../../../bin
- include(../../../WebKit.pri)
- +# For common font initialization code
- +INCLUDEPATH += ../../../WebKitTools/DumpRenderTree/qt
- +
- QT += network
- macx:QT+=xml
- QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
- diff --git a/WebKit/qt/QtLauncher/main.cpp b/WebKit/qt/QtLauncher/main.cpp
- index 2286712..0fd499c 100644
- --- a/WebKit/qt/QtLauncher/main.cpp
- +++ b/WebKit/qt/QtLauncher/main.cpp
- @@ -54,11 +54,14 @@
- #include <qwebsettings.h>
- #include <qwebview.h>
- +#include <SharedInitialization.h>
- #ifndef NDEBUG
- void QWEBKIT_EXPORT qt_drt_garbageCollector_collect();
- #endif
- +extern void qt_drt_run(bool b);
- +
- static QUrl urlFromUserInput(const QString& input)
- {
- #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
- @@ -599,6 +602,12 @@ int launcherMain(const QApplication& app)
- int main(int argc, char **argv)
- {
- +#if QT_VERSION >= 0x040500
- + for (int i = 0; i < argc; ++i)
- + if (!qstrcmp(argv[i], "--like-drt"))
- + QApplication::setGraphicsSystem("raster");
- +#endif
- +
- QApplication app(argc, argv);
- QString defaultUrl = QString("file://%1/%2").arg(QDir::homePath()).arg(QLatin1String("index.html"));
- @@ -619,6 +628,12 @@ int main(int argc, char **argv)
- const QStringList args = app.arguments();
- + if (args.contains(QLatin1String("--like-drt"))) {
- + QApplication::setStyle(new QWindowsStyle);
- + WebCore::initializeDRTFonts();
- + qt_drt_run(true);
- + }
- +
- if (args.contains(QLatin1String("-r"))) {
- // robotized
- QString listFile = args.at(2);
- diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
- index 0b30710..57564be 100644
- --- a/WebKitTools/ChangeLog
- +++ b/WebKitTools/ChangeLog
- @@ -1,3 +1,22 @@
- +2009-12-14 Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
- +
- + Reviewed by Simon Hausmann.
- +
- + Make the Qt DRT use a fixed set of SVG fonts for all text rendering
- +
- + On startup we load a set of SVG fonts for the generic font families
- + and instruct the DRT to use only these fonts, even when asked for
- + families where there's a system font available.
- +
- + Hopefully this should give us cross-platform DRT results between Mac,
- + Linux and Windows, and possibly other platforms, without variations in
- + font metrics based on the underlying font engines on each platform.
- +
- + * DumpRenderTree/qt/DumpRenderTree.cpp:
- + * DumpRenderTree/qt/DumpRenderTree.h:
- + * DumpRenderTree/qt/main.cpp:
- + * Scripts/run-webkit-tests:
- +
- 2009-12-07 Dirk Schulze <krit@webkit.org>
- Not reviewed, adding myself to the reviewers list.
- diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp
- index 6d466bf..71ee09c 100644
- --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp
- +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.cpp
- @@ -438,11 +438,6 @@ void DumpRenderTree::open(const QUrl& aurl)
- QFocusEvent ev(QEvent::FocusIn);
- m_page->event(&ev);
- - QFontDatabase::removeAllApplicationFonts();
- -#if defined(Q_WS_X11)
- - initializeFonts();
- -#endif
- -
- qt_dump_frame_loader(url.toString().contains("loading/"));
- setTextOutputEnabled(true);
- m_page->mainFrame()->load(url);
- @@ -750,44 +745,4 @@ int DumpRenderTree::windowCount() const
- return windows.count() + 1;
- }
- -#if defined(Q_WS_X11)
- -void DumpRenderTree::initializeFonts()
- -{
- - static int numFonts = -1;
- -
- - // Some test cases may add or remove application fonts (via @font-face).
- - // Make sure to re-initialize the font set if necessary.
- - FcFontSet* appFontSet = FcConfigGetFonts(0, FcSetApplication);
- - if (appFontSet && numFonts >= 0 && appFontSet->nfont == numFonts)
- - return;
- -
- - QByteArray fontDir = getenv("WEBKIT_TESTFONTS");
- - if (fontDir.isEmpty() || !QDir(fontDir).exists()) {
- - fprintf(stderr,
- - "\n\n"
- - "----------------------------------------------------------------------\n"
- - "WEBKIT_TESTFONTS environment variable is not set correctly.\n"
- - "This variable has to point to the directory containing the fonts\n"
- - "you can clone from git://gitorious.org/qtwebkit/testfonts.git\n"
- - "----------------------------------------------------------------------\n"
- - );
- - exit(1);
- - }
- - char currentPath[PATH_MAX+1];
- - if (!getcwd(currentPath, PATH_MAX))
- - qFatal("Couldn't get current working directory");
- - QByteArray configFile = currentPath;
- - FcConfig *config = FcConfigCreate();
- - configFile += "/WebKitTools/DumpRenderTree/qt/fonts.conf";
- - if (!FcConfigParseAndLoad (config, (FcChar8*) configFile.data(), true))
- - qFatal("Couldn't load font configuration file");
- - if (!FcConfigAppFontAddDir (config, (FcChar8*) fontDir.data()))
- - qFatal("Couldn't add font dir!");
- - FcConfigSetCurrent(config);
- -
- - appFontSet = FcConfigGetFonts(config, FcSetApplication);
- - numFonts = appFontSet->nfont;
- -}
- -#endif
- -
- }
- diff --git a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h
- index ab229fe..cd5d508 100644
- --- a/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h
- +++ b/WebKitTools/DumpRenderTree/qt/DumpRenderTree.h
- @@ -91,11 +91,6 @@ public:
- WebPage *webPage() const { return m_page; }
- -
- -#if defined(Q_WS_X11)
- - static void initializeFonts();
- -#endif
- -
- public Q_SLOTS:
- void initJSObjects();
- void readStdin(int);
- diff --git a/WebKitTools/DumpRenderTree/qt/SharedInitialization.h b/WebKitTools/DumpRenderTree/qt/SharedInitialization.h
- new file mode 100644
- index 0000000..6ac4df8
- --- /dev/null
- +++ b/WebKitTools/DumpRenderTree/qt/SharedInitialization.h
- @@ -0,0 +1,66 @@
- +/*
- + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
- +
- + This library is free software; you can redistribute it and/or
- + modify it under the terms of the GNU Library General Public
- + License as published by the Free Software Foundation; either
- + version 2 of the License, or (at your option) any later version.
- +
- + This library is distributed in the hope that it will be useful,
- + but WITHOUT ANY WARRANTY; without even the implied warranty of
- + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + Library General Public License for more details.
- +
- + You should have received a copy of the GNU Library General Public License
- + along with this library; see the file COPYING.LIB. If not, write to
- + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- + Boston, MA 02110-1301, USA.
- +*/
- +
- +#ifndef SHAREDINITIALIZATION_H
- +#define SHAREDINITIALIZATION_H
- +
- +#include <QDir>
- +#include <QResource>
- +#include <QFont>
- +#include <QFile>
- +
- +#include <qwebsecurityorigin.h>
- +
- +namespace WebCore {
- +
- +void initializeDRTFonts()
- +{
- + QByteArray fontsDir = qgetenv("WEBKIT_TESTFONTS");
- + if (fontsDir.isEmpty() || !QDir(fontsDir).exists()) {
- + fprintf(stderr, "\n\n"
- + "----------------------------------------------------------------------\n"
- + "WEBKIT_TESTFONTS environment variable is not set correctly.\n"
- + "This variable has to point to the directory containing the fonts\n"
- + "you can clone from git://gitorious.org/qtwebkit/testfonts.git\n"
- + "----------------------------------------------------------------------\n");
- + exit(1);
- + }
- +
- + if (!QResource::registerResource(fontsDir + QLatin1String("/fonts.bin")))
- + qFatal("Could not load $WEBKIT_TESTFONTS/fonts.bin");
- +
- + QFile fontsCssFile(":/fonts.css");
- + if (!fontsCssFile.open(QFile::ReadOnly))
- + qFatal("Failed to read fonts.css from binary resource 'fonts.bin'");
- +
- + QWebSettings::globalSettings()->setUserStyleSheetUrl(QUrl("data:text/css;charset=utf-8;base64,"
- + + fontsCssFile.readAll().toBase64()));
- +
- + QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont, QLatin1String("-webkit-standard"));
- +
- + // Lets us load the SVG fonts using qrc from both data: and non-file URLs
- + QWebSecurityOrigin::removeLocalScheme("qrc");
- +
- + // While still allowing local content such as files to load the SVG fonts
- + QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
- +}
- +
- +} // WebCore
- +
- +#endif // SHAREDINITIALIZATION_H
- diff --git a/WebKitTools/DumpRenderTree/qt/main.cpp b/WebKitTools/DumpRenderTree/qt/main.cpp
- index 719315f..a714a86 100644
- --- a/WebKitTools/DumpRenderTree/qt/main.cpp
- +++ b/WebKitTools/DumpRenderTree/qt/main.cpp
- @@ -42,6 +42,8 @@
- #include <qdesktopservices.h>
- #include <qwindowsstyle.h>
- +#include "SharedInitialization.h"
- +
- #ifdef Q_WS_X11
- #include <qx11info_x11.h>
- #include <fontconfig/fontconfig.h>
- @@ -98,10 +100,7 @@ static NO_RETURN void crashHandler(int sig)
- int main(int argc, char* argv[])
- {
- -#ifdef Q_WS_X11
- - FcInit();
- - WebCore::DumpRenderTree::initializeFonts();
- -#endif
- + WebCore::initializeDRTFonts();
- #if QT_VERSION >= 0x040500
- QApplication::setGraphicsSystem("raster");
- diff --git a/WebKitTools/Scripts/run-webkit-tests b/WebKitTools/Scripts/run-webkit-tests
- index 6dd8339..b04ba4f 100755
- --- a/WebKitTools/Scripts/run-webkit-tests
- +++ b/WebKitTools/Scripts/run-webkit-tests
- @@ -1024,7 +1024,7 @@ my @configurationArgs = argumentsForConfiguration();
- if (isGtk()) {
- system "WebKitTools/Scripts/run-launcher", @configurationArgs, "file://".$testResults if $launchSafari;
- } elsif (isQt()) {
- - unshift @configurationArgs, qw(-graphicssystem raster -style windows);
- + unshift @configurationArgs, qw(--like-drt);
- system "WebKitTools/Scripts/run-launcher", @configurationArgs, "file://".$testResults if $launchSafari;
- } elsif (isCygwin()) {
- system "cygstart", $testResults if $launchSafari;
Add Comment
Please, Sign In to add comment