2011-03-13 Joe Wild <joseph.wild@nokia.com>

        Reviewed by Kenneth Rohde Christiansen.

        [Qt] QtLauncher does not load the same set of fonts as the DRT
        https://bugs.webkit.org/show_bug.cgi?id=34959

        This patch adds the option "-use-test-fonts" to the QtTestBrowser.
        When this option is used the webkit fonts are loaded the same
        as they are in DumpRenderTree.  This option can be used on
        QtTestBrowser and run-launcher.  It can only be used
        on Linux systems with FcInit and is configured as such.

        * QtTestBrowser/launcherwindow.h:
        (WindowOptions::WindowOptions):
        * QtTestBrowser/main.cpp:
        (initWebKitTestFonts):
        (launcherMain):
        (LauncherApplication::handleUserOptions):

git-svn-id: svn://svn.chromium.org/blink/trunk@80977 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 51f40272
2011-03-13 Joe Wild <joseph.wild@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
[Qt] QtLauncher does not load the same set of fonts as the DRT
https://bugs.webkit.org/show_bug.cgi?id=34959
This patch adds the option "-use-test-fonts" to the QtTestBrowser.
When this option is used the webkit fonts are loaded the same
as they are in DumpRenderTree. This option can be used on
QtTestBrowser and run-launcher. It can only be used
on Linux systems with FcInit and is configured as such.
* QtTestBrowser/launcherwindow.h:
(WindowOptions::WindowOptions):
* QtTestBrowser/main.cpp:
(initWebKitTestFonts):
(launcherMain):
(LauncherApplication::handleUserOptions):
2011-03-12 Dan Bernstein <mitz@apple.com> 2011-03-12 Dan Bernstein <mitz@apple.com>
Reviewed by Mark Rowe. Reviewed by Mark Rowe.
......
...@@ -99,6 +99,9 @@ public: ...@@ -99,6 +99,9 @@ public:
, offlineStorageDefaultQuotaSize(0) , offlineStorageDefaultQuotaSize(0)
#if defined(QT_CONFIGURED_WITH_OPENGL) #if defined(QT_CONFIGURED_WITH_OPENGL)
, useQGLWidgetViewport(false) , useQGLWidgetViewport(false)
#endif
#if defined(Q_WS_X11)
, useTestFonts(false)
#endif #endif
{ {
} }
...@@ -118,6 +121,9 @@ public: ...@@ -118,6 +121,9 @@ public:
quint64 offlineStorageDefaultQuotaSize; quint64 offlineStorageDefaultQuotaSize;
#if defined(QT_CONFIGURED_WITH_OPENGL) #if defined(QT_CONFIGURED_WITH_OPENGL)
bool useQGLWidgetViewport; bool useQGLWidgetViewport;
#endif
#if defined(Q_WS_X11)
bool useTestFonts;
#endif #endif
QUrl inspectorUrl; QUrl inspectorUrl;
quint16 remoteInspectorPort; quint16 remoteInspectorPort;
......
...@@ -35,8 +35,68 @@ ...@@ -35,8 +35,68 @@
WindowOptions windowOptions; WindowOptions windowOptions;
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QFontDatabase>
#if defined(Q_WS_X11)
#include <fontconfig/fontconfig.h>
#endif
#if defined(Q_WS_X11)
// Very similar to WebCore::DumpRenderTree::initializeFonts();
// Duplicated here so that QtTestBrowser would display contents
// with the same fonts as run-webkit-tests/DumpRenderTree.
static void initTestFonts()
{
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);
}
// Looks for qt/fonts.conf relative to the directory of the QtTestBrowser
// executable.
QString configFileString = QCoreApplication::applicationDirPath();
configFileString += "/../../../Tools/DumpRenderTree/qt/fonts.conf";
QByteArray configFileArray = configFileString.toUtf8();
FcConfig* config = FcConfigCreate();
if (!FcConfigParseAndLoad (config, (FcChar8*) configFileArray.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
int launcherMain(const QApplication& app) int launcherMain(const QApplication& app)
{ {
#ifdef Q_WS_X11
if (windowOptions.useTestFonts)
initTestFonts();
#endif
#ifndef NDEBUG #ifndef NDEBUG
int retVal = app.exec(); int retVal = app.exec();
DumpRenderTreeSupportQt::garbageCollectorCollect(); DumpRenderTreeSupportQt::garbageCollectorCollect();
...@@ -130,6 +190,9 @@ void LauncherApplication::handleUserOptions() ...@@ -130,6 +190,9 @@ void LauncherApplication::handleUserOptions()
<< "[-offline-storage-database-enabled]" << "[-offline-storage-database-enabled]"
<< "[-offline-web-application-cache-enabled]" << "[-offline-web-application-cache-enabled]"
<< "[-set-offline-storage-default-quota maxSize]" << "[-set-offline-storage-default-quota maxSize]"
#if defined(Q_WS_X11)
<< "[-use-test-fonts]"
#endif
<< "URLs"; << "URLs";
appQuit(0); appQuit(0);
} }
...@@ -202,6 +265,11 @@ void LauncherApplication::handleUserOptions() ...@@ -202,6 +265,11 @@ void LauncherApplication::handleUserOptions()
} }
#endif #endif
#if defined(Q_WS_X11)
if (args.contains("-use-test-fonts"))
windowOptions.useTestFonts = true;
#endif
QString inspectorUrlArg("-inspector-url"); QString inspectorUrlArg("-inspector-url");
int inspectorUrlIndex = args.indexOf(inspectorUrlArg); int inspectorUrlIndex = args.indexOf(inspectorUrlArg);
if (inspectorUrlIndex != -1) if (inspectorUrlIndex != -1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment