Changeset 48791 in webkit


Ignore:
Timestamp:
Sep 26, 2009 10:51:12 AM (15 years ago)
Author:
eric@webkit.org
Message:

2009-09-26 Zan Dobersek <zandobersek@gmail.com>

Reviewed by Gustavo Noronha.

[Layout tests] [Gtk] Gtk DumpRenderTree should use WebKit test fonts
https://bugs.webkit.org/show_bug.cgi?id=29689

Load test fonts through FontConfig before each test.
This ensures a more proper rendering of the tests.

  • DumpRenderTree/gtk/DumpRenderTree.cpp: (initializeFonts): (runTest): (main):
  • DumpRenderTree/gtk/fonts.conf: Copied from WebKitTools/DumpRenderTree/qt/fonts.conf.
  • GNUmakefile.am:
Location:
trunk/WebKitTools
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r48772 r48791  
     12009-09-26  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        Reviewed by Gustavo Noronha.
     4
     5        [Layout tests] [Gtk] Gtk DumpRenderTree should use WebKit test fonts
     6        https://bugs.webkit.org/show_bug.cgi?id=29689
     7
     8        Load test fonts through FontConfig before each test.
     9        This ensures a more proper rendering of the tests.
     10
     11        * DumpRenderTree/gtk/DumpRenderTree.cpp:
     12        (initializeFonts):
     13        (runTest):
     14        (main):
     15        * DumpRenderTree/gtk/fonts.conf: Copied from WebKitTools/DumpRenderTree/qt/fonts.conf.
     16        * GNUmakefile.am:
     17
    1182009-09-25  David Kilzer  <ddkilzer@apple.com>
    219
  • trunk/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp

    r48721 r48791  
    4545#include <wtf/Assertions.h>
    4646
     47#if PLATFORM(X11)
     48#include <fontconfig/fontconfig.h>
     49#endif
     50
    4751#include <cassert>
    4852#include <getopt.h>
     
    126130    g_free(oldString);
    127131}
     132
     133#if PLATFORM(X11)
     134static void initializeFonts()
     135{
     136    static int numFonts = -1;
     137
     138    // Some tests may add or remove fonts via the @font-face rule.
     139    // If that happens, font config should be re-created to suppress any unwanted change.
     140    FcFontSet* appFontSet = FcConfigGetFonts(0, FcSetApplication);
     141    if (appFontSet && numFonts >= 0 && appFontSet->nfont == numFonts)
     142        return;
     143
     144    const char* fontDirEnv = g_getenv("WEBKIT_TESTFONTS");
     145    if (!fontDirEnv)
     146        g_error("WEBKIT_TESTFONTS environment variable is not set, but it should point to the directory "
     147                "containing the fonts you can clone from git://gitorious.org/qtwebkit/testfonts.git\n");
     148
     149    GFile* fontDir = g_file_new_for_path(fontDirEnv);
     150    if (!fontDir || !g_file_query_exists(fontDir, NULL))
     151        g_error("WEBKIT_TESTFONTS environment variable is not set correctly - it should point to the directory "
     152                "containing the fonts you can clone from git://gitorious.org/qtwebkit/testfonts.git\n");
     153
     154    FcConfig *config = FcConfigCreate();
     155    if (!FcConfigParseAndLoad (config, (FcChar8*) FONTS_CONF_FILE, true))
     156        g_error("Couldn't load font configuration file");
     157    if (!FcConfigAppFontAddDir (config, (FcChar8*) g_file_get_path(fontDir)))
     158        g_error("Couldn't add font dir!");
     159    FcConfigSetCurrent(config);
     160
     161    g_object_unref(fontDir);
     162
     163    appFontSet = FcConfigGetFonts(config, FcSetApplication);
     164    numFonts = appFontSet->nfont;
     165}
     166#endif
    128167
    129168static gchar* dumpFramesAsText(WebKitWebFrame* frame)
     
    430469    if (prevTestBFItem)
    431470        g_object_ref(prevTestBFItem);
     471
     472#if PLATFORM(X11)
     473    initializeFonts();
     474#endif
    432475
    433476    // Focus the web view before loading the test to avoid focusing problems
     
    708751    gtk_init(&argc, &argv);
    709752
     753#if PLATFORM(X11)
     754    FcInit();
     755    initializeFonts();
     756#endif
     757
    710758    struct option options[] = {
    711759        {"notree", no_argument, &dumpTree, false},
  • trunk/WebKitTools/GNUmakefile.am

    r48228 r48791  
    108108
    109109dumprendertree_cppflags += \
    110         -DTEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\"
     110        -DTEST_PLUGIN_DIR=\"${shell pwd}/${top_builddir}/TestNetscapePlugin/.libs\" \
     111        -DFONTS_CONF_FILE=\"${shell pwd}/${srcdir}/WebKitTools/DumpRenderTree/gtk/fonts.conf\"
    111112
    112113TestNetscapePlugin_libtestnetscapeplugin_la_CPPFLAGS = \
Note: See TracChangeset for help on using the changeset viewer.