Title: [105876] trunk/Tools
Revision
105876
Author
[email protected]
Date
2012-01-25 07:03:01 -0800 (Wed, 25 Jan 2012)

Log Message

[Qt] Cleanup testfonts handling
https://bugs.webkit.org/show_bug.cgi?id=76068

Reviewed by Simon Hausmann.

Factor test font initialization into it's own file  so test
font users can share the implementation by adding the file
to their build.
Use fonts.conf from the test font directory to not require the
current directory to be the WebKit root.
Fix the -use-test-fonts option of QtTestBrowser by initializing
the fonts earlier, before it is too late (namely before calling
show on the main window).

* DumpRenderTree/qt/DumpRenderTree.pro:
* DumpRenderTree/qt/DumpRenderTreeQt.cpp:
(WebCore::DumpRenderTree::open):
* DumpRenderTree/qt/DumpRenderTreeQt.h:
* DumpRenderTree/qt/QtInitializeTestFonts.cpp: Copied from Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp.
(WebKit::initializeTestFonts):
* DumpRenderTree/qt/QtInitializeTestFonts.h: Added.
* DumpRenderTree/qt/fonts.conf: Removed. No need for this since
we will use the one from the test fonts directory.
* DumpRenderTree/qt/main.cpp:
(main): Fix the ifdefs to make it clear that the code to
set up the Dpi has not been ported to Qt5 yet.
* QtTestBrowser/QtTestBrowser.pro:
* QtTestBrowser/launcherwindow.h:
(WindowOptions::WindowOptions):
* QtTestBrowser/main.cpp:
(launcherMain):
(LauncherApplication::handleUserOptions):
* WebKitTestRunner/InjectedBundle/Target.pri:
* WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp:
(WTR::activateFonts): Remove the code to set up the Dpi
because it does not work with Qt5.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (105875 => 105876)


--- trunk/Tools/ChangeLog	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/ChangeLog	2012-01-25 15:03:01 UTC (rev 105876)
@@ -1,3 +1,42 @@
+2012-01-24  Balazs Kelemen  <[email protected]>
+
+        [Qt] Cleanup testfonts handling
+        https://bugs.webkit.org/show_bug.cgi?id=76068
+
+        Reviewed by Simon Hausmann.
+
+        Factor test font initialization into it's own file  so test
+        font users can share the implementation by adding the file
+        to their build.
+        Use fonts.conf from the test font directory to not require the
+        current directory to be the WebKit root.
+        Fix the -use-test-fonts option of QtTestBrowser by initializing
+        the fonts earlier, before it is too late (namely before calling
+        show on the main window).
+
+        * DumpRenderTree/qt/DumpRenderTree.pro:
+        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
+        (WebCore::DumpRenderTree::open):
+        * DumpRenderTree/qt/DumpRenderTreeQt.h:
+        * DumpRenderTree/qt/QtInitializeTestFonts.cpp: Copied from Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp.
+        (WebKit::initializeTestFonts):
+        * DumpRenderTree/qt/QtInitializeTestFonts.h: Added.
+        * DumpRenderTree/qt/fonts.conf: Removed. No need for this since
+        we will use the one from the test fonts directory.
+        * DumpRenderTree/qt/main.cpp:
+        (main): Fix the ifdefs to make it clear that the code to
+        set up the Dpi has not been ported to Qt5 yet.
+        * QtTestBrowser/QtTestBrowser.pro:
+        * QtTestBrowser/launcherwindow.h:
+        (WindowOptions::WindowOptions):
+        * QtTestBrowser/main.cpp:
+        (launcherMain):
+        (LauncherApplication::handleUserOptions):
+        * WebKitTestRunner/InjectedBundle/Target.pri:
+        * WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp:
+        (WTR::activateFonts): Remove the code to set up the Dpi
+        because it does not work with Qt5.
+
 2012-01-25  Simon Hausmann  <[email protected]>
 
         [Qt] build-webkit --qt requires a git-svn or SVN checkout.

Modified: trunk/Tools/DumpRenderTree/qt/DumpRenderTree.pro (105875 => 105876)


--- trunk/Tools/DumpRenderTree/qt/DumpRenderTree.pro	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/DumpRenderTree/qt/DumpRenderTree.pro	2012-01-25 15:03:01 UTC (rev 105876)
@@ -34,6 +34,7 @@
     LayoutTestControllerQt.h \
     GCControllerQt.h \
     PlainTextControllerQt.h \
+    QtInitializeTestFonts.h \
     testplugin.h
 
 SOURCES += \
@@ -46,6 +47,7 @@
     WorkQueueItemQt.cpp \
     LayoutTestControllerQt.cpp \
     GCControllerQt.cpp \
+    QtInitializeTestFonts.cpp \
     testplugin.cpp \
     main.cpp
 

Modified: trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp (105875 => 105876)


--- trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.cpp	2012-01-25 15:03:01 UTC (rev 105876)
@@ -38,6 +38,7 @@
 #include "LayoutTestControllerQt.h"
 #include "TextInputControllerQt.h"
 #include "PlainTextControllerQt.h"
+#include "QtInitializeTestFonts.h"
 #include "testplugin.h"
 #include "WorkQueue.h"
 
@@ -66,10 +67,6 @@
 #include <qwebsettings.h>
 #include <qwebsecurityorigin.h>
 
-#if HAVE(FONTCONFIG)
-#include <fontconfig/fontconfig.h>
-#endif
-
 #include <limits.h>
 #include <locale.h>
 
@@ -629,7 +626,7 @@
 #if !(QT_VERSION <= QT_VERSION_CHECK(4, 6, 2))
     QFontDatabase::removeAllApplicationFonts();
 #endif
-    initializeFonts();
+    WebKit::initializeTestFonts();
 
     DumpRenderTreeSupportQt::dumpFrameLoader(url.toString().contains("loading/"));
     setTextOutputEnabled(true);
@@ -1141,46 +1138,4 @@
     return pages;
 }
 
-void DumpRenderTree::initializeFonts()
-{
-#if HAVE(FONTCONFIG)
-    static int numFonts = -1;
-
-    FcInit();
-
-    // 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 += "/Tools/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
 }
-
-}

Modified: trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.h (105875 => 105876)


--- trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.h	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/DumpRenderTree/qt/DumpRenderTreeQt.h	2012-01-25 15:03:01 UTC (rev 105876)
@@ -102,8 +102,6 @@
     WebPage *webPage() const { return m_page; }
     QList<WebPage*> getAllPages() const;
 
-    static void initializeFonts();
-
     void processArgsLine(const QStringList&);
     void setRedirectOutputFileName(const QString& fileName) { m_redirectOutputFileName = fileName; }
     void setRedirectErrorFileName(const QString& fileName) { m_redirectErrorFileName = fileName; }

Copied: trunk/Tools/DumpRenderTree/qt/QtInitializeTestFonts.cpp (from rev 105875, trunk/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp) (0 => 105876)


--- trunk/Tools/DumpRenderTree/qt/QtInitializeTestFonts.cpp	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/qt/QtInitializeTestFonts.cpp	2012-01-25 15:03:01 UTC (rev 105876)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "QtInitializeTestFonts.h"
+
+#if defined(HAVE_FONTCONFIG) && HAVE_FONTCONFIG
+#include <QByteArray>
+#include <QDir>
+#include <fontconfig/fontconfig.h>
+#endif
+
+namespace WebKit {
+
+void initializeTestFonts()
+{
+#if defined(HAVE_FONTCONFIG) && HAVE_FONTCONFIG
+    static int numFonts = -1;
+
+    FcInit();
+
+    // 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(QString::fromLatin1(fontDir)).exists()) {
+        qFatal("\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"
+               );
+    }
+
+    QByteArray configFile = fontDir + "/fonts.conf";
+    FcConfig* config = FcConfigCreate();
+    if (!FcConfigParseAndLoad(config, reinterpret_cast<const FcChar8*>(configFile.constData()), FcTrue))
+        qFatal("Couldn't load font configuration file");
+    if (!FcConfigAppFontAddDir(config, reinterpret_cast<const FcChar8*>(fontDir.data())))
+        qFatal("Couldn't add font dir!");
+    FcConfigSetCurrent(config);
+
+    appFontSet = FcConfigGetFonts(config, FcSetApplication);
+    numFonts = appFontSet->nfont;
+#endif
+}
+
+}

Added: trunk/Tools/DumpRenderTree/qt/QtInitializeTestFonts.h (0 => 105876)


--- trunk/Tools/DumpRenderTree/qt/QtInitializeTestFonts.h	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/qt/QtInitializeTestFonts.h	2012-01-25 15:03:01 UTC (rev 105876)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef QtInitializeTestFonts_h
+#define QtInitializeTestFonts_h
+
+namespace WebKit {
+
+// Helper to share code between test font users.
+void initializeTestFonts();
+
+}
+
+#endif

Deleted: trunk/Tools/DumpRenderTree/qt/fonts.conf (105875 => 105876)


--- trunk/Tools/DumpRenderTree/qt/fonts.conf	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/DumpRenderTree/qt/fonts.conf	2012-01-25 15:03:01 UTC (rev 105876)
@@ -1,275 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
-<fontconfig>
-
-<!--
-  Accept deprecated 'mono' alias, replacing it with 'monospace'
--->
-	<match target="pattern">
-		<test qual="any" name="family">
-			<string>mono</string>
-		</test>
-		<edit name="family" mode="assign">
-			<string>monospace</string>
-		</edit>
-	</match>
-
-<!--
-  Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
--->
-	<match target="pattern">
-		<test qual="any" name="family">
-			<string>sans serif</string>
-		</test>
-		<edit name="family" mode="assign">
-			<string>sans-serif</string>
-		</edit>
-	</match>
-
-<!--
-  Accept deprecated 'sans' alias, replacing it with 'sans-serif'
--->
-	<match target="pattern">
-		<test qual="any" name="family">
-			<string>sans</string>
-		</test>
-		<edit name="family" mode="assign">
-			<string>sans-serif</string>
-		</edit>
-	</match>
-
-<!--
-  If the font still has no generic name, add sans-serif
- -->
-	<match target="pattern">
-		<test qual="all" name="family" compare="not_eq">
-			<string>sans-serif</string>
-		</test>
-		<test qual="all" name="family" compare="not_eq">
-			<string>serif</string>
-		</test>
-		<test qual="all" name="family" compare="not_eq">
-			<string>monospace</string>
-		</test>
-		<edit name="family" mode="append_last">
-			<string>sans-serif</string>
-		</edit>
-	</match>
-
-	<config>
-<!--
-  These are the default Unicode chars that are expected to be blank
-  in fonts.  All other blank chars are assumed to be broken and
-  won't appear in the resulting charsets
- -->
-		<blank>
-			<int>0x0020</int>	<!-- SPACE -->
-			<int>0x00A0</int>	<!-- NO-BREAK SPACE -->
-			<int>0x00AD</int>	<!-- SOFT HYPHEN -->
-			<int>0x034F</int>	<!-- COMBINING GRAPHEME JOINER -->
-			<int>0x0600</int>	<!-- ARABIC NUMBER SIGN -->
-			<int>0x0601</int>	<!-- ARABIC SIGN SANAH -->
-			<int>0x0602</int>	<!-- ARABIC FOOTNOTE MARKER -->
-			<int>0x0603</int>	<!-- ARABIC SIGN SAFHA -->
-			<int>0x06DD</int>	<!-- ARABIC END OF AYAH -->
-			<int>0x070F</int>	<!-- SYRIAC ABBREVIATION MARK -->
-			<int>0x115F</int>	<!-- HANGUL CHOSEONG FILLER -->
-			<int>0x1160</int>	<!-- HANGUL JUNGSEONG FILLER -->
-			<int>0x1680</int>	<!-- OGHAM SPACE MARK -->
-			<int>0x17B4</int>	<!-- KHMER VOWEL INHERENT AQ -->
-			<int>0x17B5</int>	<!-- KHMER VOWEL INHERENT AA -->
-			<int>0x180E</int>	<!-- MONGOLIAN VOWEL SEPARATOR -->
-			<int>0x2000</int>	<!-- EN QUAD -->
-			<int>0x2001</int>	<!-- EM QUAD -->
-			<int>0x2002</int>	<!-- EN SPACE -->
-			<int>0x2003</int>	<!-- EM SPACE -->
-			<int>0x2004</int>	<!-- THREE-PER-EM SPACE -->
-			<int>0x2005</int>	<!-- FOUR-PER-EM SPACE -->
-			<int>0x2006</int>	<!-- SIX-PER-EM SPACE -->
-			<int>0x2007</int>	<!-- FIGURE SPACE -->
-			<int>0x2008</int>	<!-- PUNCTUATION SPACE -->
-			<int>0x2009</int>	<!-- THIN SPACE -->
-			<int>0x200A</int>	<!-- HAIR SPACE -->
-			<int>0x200B</int>	<!-- ZERO WIDTH SPACE -->
-			<int>0x200C</int>	<!-- ZERO WIDTH NON-JOINER -->
-			<int>0x200D</int>	<!-- ZERO WIDTH JOINER -->
-			<int>0x200E</int>	<!-- LEFT-TO-RIGHT MARK -->
-			<int>0x200F</int>	<!-- RIGHT-TO-LEFT MARK -->
-			<int>0x2028</int>	<!-- LINE SEPARATOR -->
-			<int>0x2029</int>	<!-- PARAGRAPH SEPARATOR -->
-			<int>0x202A</int>	<!-- LEFT-TO-RIGHT EMBEDDING -->
-			<int>0x202B</int>	<!-- RIGHT-TO-LEFT EMBEDDING -->
-			<int>0x202C</int>	<!-- POP DIRECTIONAL FORMATTING -->
-			<int>0x202D</int>	<!-- LEFT-TO-RIGHT OVERRIDE -->
-			<int>0x202E</int>	<!-- RIGHT-TO-LEFT OVERRIDE -->
-			<int>0x202F</int>	<!-- NARROW NO-BREAK SPACE -->
-			<int>0x205F</int>	<!-- MEDIUM MATHEMATICAL SPACE -->
-			<int>0x2060</int>	<!-- WORD JOINER -->
-			<int>0x2061</int>	<!-- FUNCTION APPLICATION -->
-			<int>0x2062</int>	<!-- INVISIBLE TIMES -->
-			<int>0x2063</int>	<!-- INVISIBLE SEPARATOR -->
-			<int>0x206A</int>	<!-- INHIBIT SYMMETRIC SWAPPING -->
-			<int>0x206B</int>	<!-- ACTIVATE SYMMETRIC SWAPPING -->
-			<int>0x206C</int>	<!-- INHIBIT ARABIC FORM SHAPING -->
-			<int>0x206D</int>	<!-- ACTIVATE ARABIC FORM SHAPING -->
-			<int>0x206E</int>	<!-- NATIONAL DIGIT SHAPES -->
-			<int>0x206F</int>	<!-- NOMINAL DIGIT SHAPES -->
-			<int>0x3000</int>	<!-- IDEOGRAPHIC SPACE -->
-			<int>0x3164</int>	<!-- HANGUL FILLER -->
-			<int>0xFEFF</int>	<!-- ZERO WIDTH NO-BREAK SPACE -->
-			<int>0xFFA0</int>	<!-- HALFWIDTH HANGUL FILLER -->
-			<int>0xFFF9</int>	<!-- INTERLINEAR ANNOTATION ANCHOR -->
-			<int>0xFFFA</int>	<!-- INTERLINEAR ANNOTATION SEPARATOR -->
-			<int>0xFFFB</int>	<!-- INTERLINEAR ANNOTATION TERMINATOR -->
-		</blank>
-<!--
-  Rescan configuration every 30 seconds when FcFontSetList is called
- -->
-		<rescan>
-			<int>30</int>
-		</rescan>
-	</config>
-
-<!--
-  URW provides metric and shape compatible fonts for these 10 Adobe families.
-
-  However, these fonts are quite ugly and do not render well on-screen,
-  so we avoid matching them if the application said `anymetrics'; in that
-  case, a more generic font with different metrics but better appearance
-  will be used.
-  -->
-       	<match target="pattern">
-          <test name="family">
-            <string>Avant Garde</string>
-          </test>
-          <test name="anymetrics" qual="all" compare="not_eq">
-            <bool>true</bool>
-          </test>
-          <edit name="family" mode="append">
-            <string>URW Gothic L</string>
-          </edit>
-     	</match>
-       	<match target="pattern">
-          <test name="family">
-            <string>Bookman</string>
-          </test>
-          <test name="anymetrics" qual="all" compare="not_eq">
-            <bool>true</bool>
-          </test>
-          <edit name="family" mode="append">
-            <string>URW Bookman L</string>
-          </edit>
-     	</match>
-       	<match target="pattern">
-          <test name="family">
-            <string>Courier</string>
-          </test>
-          <test name="anymetrics" qual="all" compare="not_eq">
-            <bool>true</bool>
-          </test>
-          <edit name="family" mode="append">
-            <string>Nimbus Mono L</string>
-          </edit>
-     	</match>
-       	<match target="pattern">
-          <test name="family">
-            <string>Helvetica</string>
-          </test>
-          <test name="anymetrics" qual="all" compare="not_eq">
-            <bool>true</bool>
-          </test>
-          <edit name="family" mode="append">
-            <string>Nimbus Sans L</string>
-          </edit>
-     	</match>
-       	<match target="pattern">
-          <test name="family">
-            <string>New Century Schoolbook</string>
-          </test>
-          <test name="anymetrics" qual="all" compare="not_eq">
-            <bool>true</bool>
-          </test>
-          <edit name="family" mode="append">
-            <string>Century Schoolbook L</string>
-          </edit>
-     	</match>
-       	<match target="pattern">
-          <test name="family">
-            <string>Palatino</string>
-          </test>
-          <test name="anymetrics" qual="all" compare="not_eq">
-            <bool>true</bool>
-          </test>
-          <edit name="family" mode="append">
-            <string>URW Palladio L</string>
-          </edit>
-     	</match>
-       	<match target="pattern">
-          <test name="family">
-            <string>Times</string>
-          </test>
-          <test name="anymetrics" qual="all" compare="not_eq">
-            <bool>true</bool>
-          </test>
-          <edit name="family" mode="append">
-            <string>Nimbus Roman No9 L</string>
-          </edit>
-     	</match>
-       	<match target="pattern">
-          <test name="family">
-            <string>Zapf Chancery</string>
-          </test>
-          <test name="anymetrics" qual="all" compare="not_eq">
-            <bool>true</bool>
-          </test>
-          <edit name="family" mode="append">
-            <string>URW Chancery L</string>
-          </edit>
-     	</match>
-       	<match target="pattern">
-          <test name="family">
-            <string>Zapf Dingbats</string>
-          </test>
-          <test name="anymetrics" qual="all" compare="not_eq">
-            <bool>true</bool>
-          </test>
-          <edit name="family" mode="append">
-            <string>Dingbats</string>
-          </edit>
-     	</match>
-        <match target="pattern">
-          <test name="family">
-            <string>Symbol</string>
-          </test>
-          <test name="anymetrics" qual="all" compare="not_eq">
-            <bool>true</bool>
-          </test>
-          <edit name="family" mode="append" binding="same">
-            <string>Standard Symbols L</string>
-          </edit>
-        </match>
-
-<!--
-  Serif faces
- -->
-	<alias>
-		<family>Nimbus Roman No9 L</family>
-		<default><family>serif</family></default>
-	</alias>
-<!--
-  Sans-serif faces
- -->
-	<alias>
-		<family>Nimbus Sans L</family>
-		<default><family>sans-serif</family></default>
-	</alias>
-<!--
-  Monospace faces
- -->
- 	<alias>
-		<family>Nimbus Mono L</family>
-		<default><family>monospace</family></default>
-	</alias>
-
-
-</fontconfig>

Modified: trunk/Tools/DumpRenderTree/qt/main.cpp (105875 => 105876)


--- trunk/Tools/DumpRenderTree/qt/main.cpp	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/DumpRenderTree/qt/main.cpp	2012-01-25 15:03:01 UTC (rev 105876)
@@ -29,6 +29,8 @@
 
 #include "DumpRenderTreeQt.h"
 
+#include "QtInitializeTestFonts.h"
+
 #include <wtf/AlwaysInline.h>
 
 #include <qstringlist.h>
@@ -141,13 +143,14 @@
     if (suppressQtDebugOutput)
         qInstallMsgHandler(messageHandler);
 
-    WebCore::DumpRenderTree::initializeFonts();
+    WebKit::initializeTestFonts();
 
     QApplication::setGraphicsSystem("raster");
     QApplication::setStyle(new QWindowsStyle);
 
     QApplication app(argc, argv);
 
+#if QT_VERSION <= QT_VERSION_CHECK(5, 0, 0) // FIXME: need a way to port this to Qt5.
 #ifdef Q_WS_X11
     QX11Info::setAppDpiY(0, 96);
     QX11Info::setAppDpiX(0, 96);
@@ -165,6 +168,7 @@
     * default font, but with the correct paint-device DPI.
    */
     QApplication::setFont(QWidget().font());
+#endif
 
 #if HAVE(SIGNAL_H)
     setupSignalHandlers(&crashHandler);

Modified: trunk/Tools/QtTestBrowser/QtTestBrowser.pro (105875 => 105876)


--- trunk/Tools/QtTestBrowser/QtTestBrowser.pro	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/QtTestBrowser/QtTestBrowser.pro	2012-01-25 15:03:01 UTC (rev 105876)
@@ -6,11 +6,14 @@
 
 TEMPLATE = app
 
-INCLUDEPATH += $${ROOT_WEBKIT_DIR}/Source/WebKit/qt/WebCoreSupport
+INCLUDEPATH += \
+    $${ROOT_WEBKIT_DIR}/Source/WebKit/qt/WebCoreSupport \
+    $${ROOT_WEBKIT_DIR}/Tools/DumpRenderTree/qt/ \
 
 load(features)
 
 SOURCES += \
+    $${ROOT_WEBKIT_DIR}/Tools/DumpRenderTree/qt/QtInitializeTestFonts.cpp \
     locationedit.cpp \
     launcherwindow.cpp \
     main.cpp \
@@ -23,6 +26,7 @@
     cookiejar.cpp
 
 HEADERS += \
+    $${ROOT_WEBKIT_DIR}/Tools/DumpRenderTree/qt/QtInitializeTestFonts.h \
     locationedit.h \
     launcherwindow.h \
     mainwindow.h \

Modified: trunk/Tools/QtTestBrowser/launcherwindow.h (105875 => 105876)


--- trunk/Tools/QtTestBrowser/launcherwindow.h	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/QtTestBrowser/launcherwindow.h	2012-01-25 15:03:01 UTC (rev 105876)
@@ -83,9 +83,6 @@
 #ifndef QT_NO_OPENGL
         , useQGLWidgetViewport(false)
 #endif
-#if defined(Q_WS_X11)
-        , useTestFonts(false)
-#endif
         , printLoadedUrls(false)
         , startMaximized(false)
     {
@@ -109,9 +106,6 @@
 #ifndef QT_NO_OPENGL
     bool useQGLWidgetViewport;
 #endif
-#if defined(Q_WS_X11)
-    bool useTestFonts;
-#endif
     bool printLoadedUrls;
     QUrl inspectorUrl;
     quint16 remoteInspectorPort;

Modified: trunk/Tools/QtTestBrowser/main.cpp (105875 => 105876)


--- trunk/Tools/QtTestBrowser/main.cpp	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/QtTestBrowser/main.cpp	2012-01-25 15:03:01 UTC (rev 105876)
@@ -31,6 +31,7 @@
  */
 
 #include "DumpRenderTreeSupportQt.h"
+#include "QtInitializeTestFonts.h"
 #include "launcherwindow.h"
 #include "urlloader.h"
 
@@ -42,61 +43,8 @@
 #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)
 {
-#ifdef Q_WS_X11
-    if (windowOptions.useTestFonts)
-        initTestFonts();
-#endif
-
 #ifndef NDEBUG
     int retVal = app.exec();
     DumpRenderTreeSupportQt::garbageCollectorCollect();
@@ -199,9 +147,7 @@
              << "[-offline-storage-database-enabled]"
              << "[-offline-web-application-cache-enabled]"
              << "[-set-offline-storage-default-quota maxSize]"
-#if defined(Q_WS_X11)
              << "[-use-test-fonts]"
-#endif
              << "[-print-loaded-urls]"
              << "URLs";
         appQuit(0);
@@ -294,10 +240,8 @@
     }
 #endif
 
-#if defined(Q_WS_X11)
     if (args.contains("-use-test-fonts"))
-        windowOptions.useTestFonts = true;
-#endif
+        WebKit::initializeTestFonts();
 
     if (args.contains("-print-loaded-urls"))
         windowOptions.printLoadedUrls = true;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Target.pri (105875 => 105876)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Target.pri	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Target.pri	2012-01-25 15:03:01 UTC (rev 105876)
@@ -8,6 +8,7 @@
 TARGET = WTRInjectedBundle
 
 SOURCES += \
+    $${ROOT_WEBKIT_DIR}/Tools/DumpRenderTree/qt/QtInitializeTestFonts.cpp \
     AccessibilityController.cpp \
     AccessibilityTextMarker.cpp \
     AccessibilityTextMarkerRange.cpp \
@@ -34,6 +35,7 @@
 include(DerivedSources.pri)
 
 HEADERS += \
+    $${ROOT_WEBKIT_DIR}/Tools/DumpRenderTree/qt/QtInitializeTestFonts.h \
     AccessibilityController.h \
     AccessibilityTextMarker.h \
     AccessibilityTextMarkerRange.h \
@@ -62,7 +64,8 @@
     $$PWD/.. \
     $$PWD/Bindings \
     $${ROOT_WEBKIT_DIR}/Source/WebCore/testing/js \
-    $${ROOT_WEBKIT_DIR}/Source/WebKit/qt/WebCoreSupport
+    $${ROOT_WEBKIT_DIR}/Source/WebKit/qt/WebCoreSupport \
+    $${ROOT_WEBKIT_DIR}/Tools/DumpRenderTree/qt
 
 PREFIX_HEADER = $$PWD/../WebKitTestRunnerPrefix.h
 *-g++*:QMAKE_CXXFLAGS += "-include $$PREFIX_HEADER"

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp (105875 => 105876)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp	2012-01-25 14:32:47 UTC (rev 105875)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/qt/ActivateFontsQt.cpp	2012-01-25 15:03:01 UTC (rev 105876)
@@ -29,86 +29,23 @@
 
 #include "config.h"
 #include "ActivateFonts.h"
+#include "DumpRenderTreeSupportQt.h"
+#include "QtInitializeTestFonts.h"
 
 #include <QApplication>
-#include <QByteArray>
-#include <QDir>
-#include <QFont>
 #include <QWidget>
 #include <QWindowsStyle>
 
-#if HAVE(FONTCONFIG)
-#include <fontconfig/fontconfig.h>
-#endif
-
-#include <limits.h>
-
 namespace WTR {
 
 void activateFonts()
 {
-#if HAVE(FONTCONFIG)
-    FcInit();
+    WebKit::initializeTestFonts();
 
-    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;
-
-    char* const fontDir = getenv("WEBKIT_TESTFONTS");
-    const QString fontDirString = QString::fromLocal8Bit(fontDir);
-    if (fontDirString.isEmpty() || !QDir(fontDirString).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 += "/Tools/DumpRenderTree/qt/fonts.conf";
-    if (!FcConfigParseAndLoad (config, (FcChar8*) configFile.data(), true))
-        qFatal("Couldn't load font configuration file");
-    if (!FcConfigAppFontAddDir (config, (FcChar8*) fontDir))
-        qFatal("Couldn't add font dir!");
-    FcConfigSetCurrent(config);
-
-    appFontSet = FcConfigGetFonts(config, FcSetApplication);
-    numFonts = appFontSet->nfont;
-#endif
-
     QApplication::setGraphicsSystem(QLatin1String("raster"));
 #if HAVE(QSTYLE)
     QApplication::setStyle(new QWindowsStyle);
 #endif
-
-#if defined(Q_WS_X11)
-    QX11Info::setAppDpiX(0, 96);
-    QX11Info::setAppDpiY(0, 96);
-#endif
-
-   /*
-    * QApplication will initialize the default application font based
-    * on the application DPI at construction time, which might be
-    * different from the DPI we explicitly set using QX11Info above.
-    * See: https://bugreports.qt.nokia.com/browse/QTBUG-21603
-    *
-    * To ensure that the application font DPI matches the application
-    * DPI, we override the application font using the font we get from
-    * a QWidget, which has already been resolved against the existing
-    * default font, but with the correct paint-device DPI.
-   */
-    QApplication::setFont(QWidget().font());
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to