Title: [101712] trunk
Revision
101712
Author
[email protected]
Date
2011-12-01 14:45:18 -0800 (Thu, 01 Dec 2011)

Log Message

[GTK] Read fonts from the jhbuild root
https://bugs.webkit.org/show_bug.cgi?id=73487

Reviewed by Gustavo Noronha Silva.

Read fonts from the jhbuild root instead of from the system. This will ensure
that all testers use the same fonts instead of leaving this up to luck.

Source/_javascript_Core:

* wtf/gobject/GlibUtilities.h: Add Assertions.h which was required for the WebKit2TestRunner.

Tools:

* DumpRenderTree/gtk/DumpRenderTree.cpp:
(initializeFonts): Load fonts from jhbuild root.
* Scripts/webkitpy/layout_tests/port/gtk.py:
(GtkPort.setup_environ_for_server): Pass an environment variable containing
the path to the jhbuild root.
* WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp:
(WTR::inititializeFontConfigSetting): Load fonts from the jhbuild root.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (101711 => 101712)


--- trunk/Source/_javascript_Core/ChangeLog	2011-12-01 22:37:51 UTC (rev 101711)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-12-01 22:45:18 UTC (rev 101712)
@@ -1,5 +1,17 @@
 2011-12-01  Martin Robinson  <[email protected]>
 
+        [GTK] Read fonts from the jhbuild root
+        https://bugs.webkit.org/show_bug.cgi?id=73487
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Read fonts from the jhbuild root instead of from the system. This will ensure
+        that all testers use the same fonts instead of leaving this up to luck.
+
+        * wtf/gobject/GlibUtilities.h: Add Assertions.h which was required for the WebKit2TestRunner.
+
+2011-12-01  Martin Robinson  <[email protected]>
+
         [GTK] Add a helper function to find the current executable's path
         https://bugs.webkit.org/show_bug.cgi?id=73473
 

Modified: trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.h (101711 => 101712)


--- trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.h	2011-12-01 22:37:51 UTC (rev 101711)
+++ trunk/Source/_javascript_Core/wtf/gobject/GlibUtilities.h	2011-12-01 22:45:18 UTC (rev 101712)
@@ -20,6 +20,7 @@
 #ifndef GlibUtilities_h
 #define GlibUtilities_h
 
+#include "Assertions.h"
 #include "CString.h"
 
 CString getCurrentExecutablePath();

Modified: trunk/Tools/ChangeLog (101711 => 101712)


--- trunk/Tools/ChangeLog	2011-12-01 22:37:51 UTC (rev 101711)
+++ trunk/Tools/ChangeLog	2011-12-01 22:45:18 UTC (rev 101712)
@@ -1,3 +1,21 @@
+2011-12-01  Martin Robinson  <[email protected]>
+
+        [GTK] Read fonts from the jhbuild root
+        https://bugs.webkit.org/show_bug.cgi?id=73487
+
+        Reviewed by Gustavo Noronha Silva.
+
+        Read fonts from the jhbuild root instead of from the system. This will ensure
+        that all testers use the same fonts instead of leaving this up to luck.
+
+        * DumpRenderTree/gtk/DumpRenderTree.cpp:
+        (initializeFonts): Load fonts from jhbuild root.
+        * Scripts/webkitpy/layout_tests/port/gtk.py:
+        (GtkPort.setup_environ_for_server): Pass an environment variable containing
+        the path to the jhbuild root.
+        * WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp:
+        (WTR::inititializeFontConfigSetting): Load fonts from the jhbuild root.
+
 2011-12-01  Adam Roben  <[email protected]>
 
         Teach check-webkit-style how to check the syntax of JSON files

Modified: trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp (101711 => 101712)


--- trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp	2011-12-01 22:37:51 UTC (rev 101711)
+++ trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp	2011-12-01 22:45:18 UTC (rev 101712)
@@ -54,6 +54,7 @@
 #include <gtk/gtk.h>
 #include <webkit/webkit.h>
 #include <wtf/Assertions.h>
+#include <wtf/gobject/GlibUtilities.h>
 
 #if PLATFORM(X11)
 #include <fontconfig/fontconfig.h>
@@ -177,62 +178,25 @@
     if (!FcConfigParseAndLoad(config, reinterpret_cast<FcChar8*>(fontConfigFilename.get()), true))
         g_error("Couldn't load font configuration file from: %s", fontConfigFilename.get());
 
-    static const char *const fontDirectories[] = {
-        "/usr/share/fonts/truetype/liberation",
-        "/usr/share/fonts/truetype/ttf-liberation",
-        "/usr/share/fonts/liberation",
-        "/usr/share/fonts/truetype/ttf-dejavu",
-        "/usr/share/fonts/dejavu",
-        "/usr/share/fonts/opentype/stix",
-        "/usr/share/fonts/stix"
-    };
+    CString fontsPath = g_getenv("WEBKIT_TEST_FONTS");
+    if (fontsPath.isNull()) {
+        GOwnPtr<char> parentPath(g_path_get_dirname(getCurrentExecutablePath().data()));
+        GOwnPtr<char> alternatePath(g_build_filename(parentPath.get(), "..", "..",
+                                                     "Dependencies", "Root", "webkitgtk-test-fonts", NULL));
+        fontsPath = alternatePath.get();
+        if (!g_file_test(alternatePath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
+            g_error("WEBKIT_TEST_FONTS environment variable not set and %s does not exist", alternatePath.get());
+    }
 
-    static const char *const fontPaths[] = {
-        "LiberationMono-BoldItalic.ttf",
-        "LiberationMono-Bold.ttf",
-        "LiberationMono-Italic.ttf",
-        "LiberationMono-Regular.ttf",
-        "LiberationSans-BoldItalic.ttf",
-        "LiberationSans-Bold.ttf",
-        "LiberationSans-Italic.ttf",
-        "LiberationSans-Regular.ttf",
-        "LiberationSerif-BoldItalic.ttf",
-        "LiberationSerif-Bold.ttf",
-        "LiberationSerif-Italic.ttf",
-        "LiberationSerif-Regular.ttf",
-        "DejaVuSans.ttf",
-        "DejaVuSerif.ttf",
+    GOwnPtr<GError> error;
+    GOwnPtr<GDir> fontsDirectory(g_dir_open(fontsPath.data(), 0, &error.outPtr()));
+    while (const char* directoryEntry = g_dir_read_name(fontsDirectory.get())) {
+        if (!g_str_has_suffix(directoryEntry, ".ttf") && !g_str_has_suffix(directoryEntry, ".otf"))
+            continue;
+        GOwnPtr<gchar> fontPath(g_build_filename(fontsPath.data(), directoryEntry, NULL));
+        if (!FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(fontPath.get())))
+            g_error("Could not load font at %s!", fontPath.get());
 
-        // MathML tests require the STIX fonts.
-        "STIXGeneral.otf",
-        "STIXGeneralBolIta.otf",
-        "STIXGeneralBol.otf",
-        "STIXGeneralItalic.otf"
-    };
-
-    // TODO: Some tests use Lucida. We should load these as well, once it becomes
-    // clear how to install these fonts easily on Fedora.
-    for (size_t font = 0; font < G_N_ELEMENTS(fontPaths); font++) {
-        bool found = false;
-        for (size_t path = 0; path < G_N_ELEMENTS(fontDirectories); path++) {
-            GOwnPtr<gchar> fullPath(g_build_filename(fontDirectories[path], fontPaths[font], NULL));
-            if (g_file_test(fullPath.get(), G_FILE_TEST_EXISTS)) {
-                found = true;
-                if (!FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(fullPath.get())))
-                    g_error("Could not load font at %s!", fullPath.get());
-                else
-                    break;
-            }
-        }
-
-        if (!found) {
-            GOwnPtr<gchar> directoriesDescription;
-            for (size_t path = 0; path < G_N_ELEMENTS(fontDirectories); path++)
-                directoriesDescription.set(g_strjoin(":", directoriesDescription.release(), fontDirectories[path], NULL));
-            g_error("Could not find font %s in %s. Either install this font or file a bug "
-                    "at http://bugs.webkit.org if it is installed in another location.",
-                    fontPaths[font], directoriesDescription.get());
-        }
     }
 
     // Ahem is used by many layout tests.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py (101711 => 101712)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py	2011-12-01 22:37:51 UTC (rev 101711)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/gtk.py	2011-12-01 22:45:18 UTC (rev 101712)
@@ -89,6 +89,7 @@
         environment['TEST_RUNNER_INJECTED_BUNDLE_FILENAME'] = self._build_path('Libraries', 'libTestRunnerInjectedBundle.la')
         environment['TEST_RUNNER_TEST_PLUGIN_PATH'] = self._build_path('TestNetscapePlugin', '.libs')
         environment['WEBKIT_INSPECTOR_PATH'] = self._build_path('Programs', 'resources', 'inspector')
+        environment['WEBKIT_TEST_FONTS'] = self._build_path('..', 'Dependencies', 'Root', 'webkitgtk-test-fonts')
         return environment
 
     def _generate_all_test_configurations(self):

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp (101711 => 101712)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp	2011-12-01 22:37:51 UTC (rev 101711)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp	2011-12-01 22:45:18 UTC (rev 101712)
@@ -33,6 +33,7 @@
 
 #include <fontconfig/fontconfig.h>
 #include <gtk/gtk.h>
+#include <wtf/gobject/GlibUtilities.h>
 #include <wtf/gobject/GOwnPtr.h>
 
 namespace WTR {
@@ -71,62 +72,24 @@
     if (!FcConfigParseAndLoad(config, reinterpret_cast<FcChar8*>(fontConfigFilename.get()), true))
         g_error("Couldn't load font configuration file from: %s", fontConfigFilename.get());
 
-    static const char *const fontDirectories[] = {
-        "/usr/share/fonts/truetype/liberation",
-        "/usr/share/fonts/truetype/ttf-liberation",
-        "/usr/share/fonts/liberation",
-        "/usr/share/fonts/truetype/ttf-dejavu",
-        "/usr/share/fonts/dejavu",
-        "/usr/share/fonts/opentype/stix",
-        "/usr/share/fonts/stix"
-    };
+    CString fontsPath = g_getenv("WEBKIT_TEST_FONTS");
+    if (fontsPath.isNull()) {
+        GOwnPtr<char> parentPath(g_path_get_dirname(getCurrentExecutablePath().data()));
+        GOwnPtr<char> alternatePath(g_build_filename(parentPath.get(), "..", "..",
+                                                     "Dependencies", "Root", "webkitgtk-test-fonts", NULL));
+        fontsPath = alternatePath.get();
+        if (!g_file_test(alternatePath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
+            g_error("WEBKIT_TEST_FONTS environment variable not set and %s does not exist", alternatePath.get());
+    }
 
-    static const char *const fontPaths[] = {
-        "LiberationMono-BoldItalic.ttf",
-        "LiberationMono-Bold.ttf",
-        "LiberationMono-Italic.ttf",
-        "LiberationMono-Regular.ttf",
-        "LiberationSans-BoldItalic.ttf",
-        "LiberationSans-Bold.ttf",
-        "LiberationSans-Italic.ttf",
-        "LiberationSans-Regular.ttf",
-        "LiberationSerif-BoldItalic.ttf",
-        "LiberationSerif-Bold.ttf",
-        "LiberationSerif-Italic.ttf",
-        "LiberationSerif-Regular.ttf",
-        "DejaVuSans.ttf",
-        "DejaVuSerif.ttf",
-
-        // MathML tests require the STIX fonts.
-        "STIXGeneral.otf",
-        "STIXGeneralBolIta.otf",
-        "STIXGeneralBol.otf",
-        "STIXGeneralItalic.otf"
-    };
-
-    // TODO: Some tests use Lucida. We should load these as well, once it becomes
-    // clear how to install these fonts easily on Fedora.
-    for (size_t font = 0; font < G_N_ELEMENTS(fontPaths); font++) {
-        bool found = false;
-        for (size_t path = 0; path < G_N_ELEMENTS(fontDirectories); path++) {
-            GOwnPtr<gchar> fullPath(g_build_filename(fontDirectories[path], fontPaths[font], NULL));
-            if (g_file_test(fullPath.get(), G_FILE_TEST_EXISTS)) {
-                found = true;
-                if (!FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(fullPath.get())))
-                    g_error("Could not load font at %s!", fullPath.get());
-                else
-                    break;
-            }
-        }
-
-        if (!found) {
-            GOwnPtr<gchar> directoriesDescription;
-            for (size_t path = 0; path < G_N_ELEMENTS(fontDirectories); path++)
-                directoriesDescription.set(g_strjoin(":", directoriesDescription.release(), fontDirectories[path], NULL));
-            g_error("Could not find font %s in %s. Either install this font or file a bug "
-                    "at http://bugs.webkit.org if it is installed in another location.",
-                    fontPaths[font], directoriesDescription.get());
-        }
+    GOwnPtr<GError> error;
+    GOwnPtr<GDir> fontsDirectory(g_dir_open(fontsPath.data(), 0, &error.outPtr()));
+    while (const char* directoryEntry = g_dir_read_name(fontsDirectory.get())) {
+        if (!g_str_has_suffix(directoryEntry, ".ttf") && !g_str_has_suffix(directoryEntry, ".otf"))
+            continue;
+        GOwnPtr<gchar> fontPath(g_build_filename(fontsPath.data(), directoryEntry, NULL));
+        if (!FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(fontPath.get())))
+            g_error("Could not load font at %s!", fontPath.get());
     }
 
     // Ahem is used by many layout tests.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to