Changeset 80977 in webkit


Ignore:
Timestamp:
Mar 13, 2011 5:15:31 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

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):
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r80947 r80977  
     12011-03-13  Joe Wild  <joseph.wild@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] QtLauncher does not load the same set of fonts as the DRT
     6        https://bugs.webkit.org/show_bug.cgi?id=34959
     7
     8        This patch adds the option "-use-test-fonts" to the QtTestBrowser.
     9        When this option is used the webkit fonts are loaded the same
     10        as they are in DumpRenderTree.  This option can be used on
     11        QtTestBrowser and run-launcher.  It can only be used
     12        on Linux systems with FcInit and is configured as such.
     13
     14        * QtTestBrowser/launcherwindow.h:
     15        (WindowOptions::WindowOptions):
     16        * QtTestBrowser/main.cpp:
     17        (initWebKitTestFonts):
     18        (launcherMain):
     19        (LauncherApplication::handleUserOptions):
     20
    1212011-03-12  Dan Bernstein  <mitz@apple.com>
    222
  • trunk/Tools/QtTestBrowser/launcherwindow.h

    r79668 r80977  
    101101        , useQGLWidgetViewport(false)
    102102#endif
     103#if defined(Q_WS_X11)
     104        , useTestFonts(false)
     105#endif
    103106    {
    104107    }
     
    119122#if defined(QT_CONFIGURED_WITH_OPENGL)
    120123    bool useQGLWidgetViewport;
     124#endif
     125#if defined(Q_WS_X11)
     126    bool useTestFonts;
    121127#endif
    122128    QUrl inspectorUrl;
  • trunk/Tools/QtTestBrowser/main.cpp

    r77947 r80977  
    3636WindowOptions windowOptions;
    3737
     38
     39#include <QDir>
     40#include <QFile>
     41#include <QFileInfo>
     42#include <QFontDatabase>
     43
     44
     45#if defined(Q_WS_X11)
     46#include <fontconfig/fontconfig.h>
     47#endif
     48
     49
     50#if defined(Q_WS_X11)
     51// Very similar to WebCore::DumpRenderTree::initializeFonts();
     52// Duplicated here so that QtTestBrowser would display contents
     53// with the same fonts as run-webkit-tests/DumpRenderTree.
     54static void initTestFonts()
     55{
     56    static int numFonts = -1;
     57
     58    // Some test cases may add or remove application fonts (via @font-face).
     59    // Make sure to re-initialize the font set if necessary.
     60    FcFontSet* appFontSet = FcConfigGetFonts(0, FcSetApplication);
     61    if (appFontSet && numFonts >= 0 && appFontSet->nfont == numFonts)
     62        return;
     63
     64    QByteArray fontDir = getenv("WEBKIT_TESTFONTS");
     65    if (fontDir.isEmpty() || !QDir(fontDir).exists()) {
     66        fprintf(stderr,
     67                "\n\n"
     68                "----------------------------------------------------------------------\n"
     69                "WEBKIT_TESTFONTS environment variable is not set correctly.\n"
     70                "This variable has to point to the directory containing the fonts\n"
     71                "you can clone from git://gitorious.org/qtwebkit/testfonts.git\n"
     72                "----------------------------------------------------------------------\n"
     73               );
     74        exit(1);
     75    }
     76    // Looks for qt/fonts.conf relative to the directory of the QtTestBrowser
     77    // executable.
     78    QString configFileString = QCoreApplication::applicationDirPath();
     79    configFileString += "/../../../Tools/DumpRenderTree/qt/fonts.conf";
     80    QByteArray configFileArray = configFileString.toUtf8();
     81    FcConfig* config = FcConfigCreate();
     82    if (!FcConfigParseAndLoad (config, (FcChar8*) configFileArray.data(), true))
     83        qFatal("Couldn't load font configuration file");
     84    if (!FcConfigAppFontAddDir (config, (FcChar8*) fontDir.data()))
     85        qFatal("Couldn't add font dir!");
     86    FcConfigSetCurrent(config);
     87
     88    appFontSet = FcConfigGetFonts(config, FcSetApplication);
     89    numFonts = appFontSet->nfont;
     90}
     91#endif
     92
    3893int launcherMain(const QApplication& app)
    3994{
     95#ifdef Q_WS_X11
     96    if (windowOptions.useTestFonts)
     97        initTestFonts();
     98#endif
     99
    40100#ifndef NDEBUG
    41101    int retVal = app.exec();
     
    131191             << "[-offline-web-application-cache-enabled]"
    132192             << "[-set-offline-storage-default-quota maxSize]"
     193#if defined(Q_WS_X11)
     194             << "[-use-test-fonts]"
     195#endif
    133196             << "URLs";
    134197        appQuit(0);
     
    203266#endif
    204267
     268#if defined(Q_WS_X11)
     269    if (args.contains("-use-test-fonts"))
     270        windowOptions.useTestFonts = true;
     271#endif
     272
    205273    QString inspectorUrlArg("-inspector-url");
    206274    int inspectorUrlIndex = args.indexOf(inspectorUrlArg);
Note: See TracChangeset for help on using the changeset viewer.