Title: [99158] trunk/Tools
Revision
99158
Author
[email protected]
Date
2011-11-03 03:07:56 -0700 (Thu, 03 Nov 2011)

Log Message

[GTK] [WK2] ttf-liberation fonts moved to a new location (in Debian)
https://bugs.webkit.org/show_bug.cgi?id=71445

Reviewed by Martin Robinson.

* DumpRenderTree/gtk/DumpRenderTree.cpp:
(initializeFonts): set directoriesDescription only when needed.
* WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp:
(WTR::inititializeFontConfigSetting): Add the new font path for Debian fonts and
refactored the font files loading code to avoid copy/pastes, ease
maintenance and future font directories additions.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (99157 => 99158)


--- trunk/Tools/ChangeLog	2011-11-03 10:00:37 UTC (rev 99157)
+++ trunk/Tools/ChangeLog	2011-11-03 10:07:56 UTC (rev 99158)
@@ -1,3 +1,17 @@
+2011-11-03  Philippe Normand  <[email protected]>
+
+        [GTK] [WK2] ttf-liberation fonts moved to a new location (in Debian)
+        https://bugs.webkit.org/show_bug.cgi?id=71445
+
+        Reviewed by Martin Robinson.
+
+        * DumpRenderTree/gtk/DumpRenderTree.cpp:
+        (initializeFonts): set directoriesDescription only when needed.
+        * WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp:
+        (WTR::inititializeFontConfigSetting): Add the new font path for Debian fonts and
+        refactored the font files loading code to avoid copy/pastes, ease
+        maintenance and future font directories additions.
+
 2011-11-03  Carlos Garcia Campos  <[email protected]>
 
         [GTK] Remove GtkLauncher2

Modified: trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp (99157 => 99158)


--- trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp	2011-11-03 10:00:37 UTC (rev 99157)
+++ trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp	2011-11-03 10:07:56 UTC (rev 99158)
@@ -210,10 +210,6 @@
         "STIXGeneralItalic.otf"
     };
 
-    GOwnPtr<gchar> directoriesDescription;
-    for (size_t path = 0; path < G_N_ELEMENTS(fontDirectories); path++)
-        directoriesDescription.set(g_strjoin(":", directoriesDescription.release(), fontDirectories[path], NULL));
-
     // 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++) {
@@ -229,10 +225,14 @@
             }
         }
 
-        if (!found)
+        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/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp (99157 => 99158)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp	2011-11-03 10:00:37 UTC (rev 99157)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp	2011-11-03 10:07:56 UTC (rev 99158)
@@ -71,66 +71,61 @@
     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 fontPaths[][2] = {
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationMono-BoldItalic.ttf",
-          "/usr/share/fonts/liberation/LiberationMono-BoldItalic.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationMono-Bold.ttf",
-          "/usr/share/fonts/liberation/LiberationMono-Bold.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationMono-Italic.ttf",
-          "/usr/share/fonts/liberation/LiberationMono-Italic.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationMono-Regular.ttf",
-          "/usr/share/fonts/liberation/LiberationMono-Regular.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationSans-BoldItalic.ttf",
-          "/usr/share/fonts/liberation/LiberationSans-BoldItalic.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationSans-Bold.ttf",
-          "/usr/share/fonts/liberation/LiberationSans-Bold.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationSans-Italic.ttf",
-          "/usr/share/fonts/liberation/LiberationSans-Italic.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationSans-Regular.ttf",
-          "/usr/share/fonts/liberation/LiberationSans-Regular.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationSerif-BoldItalic.ttf",
-          "/usr/share/fonts/liberation/LiberationSerif-BoldItalic.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationSerif-Bold.ttf",
-          "/usr/share/fonts/liberation/LiberationSerif-Bold.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationSerif-Italic.ttf",
-          "/usr/share/fonts/liberation/LiberationSerif-Italic.ttf", },
-        { "/usr/share/fonts/truetype/ttf-liberation/LiberationSerif-Regular.ttf",
-          "/usr/share/fonts/liberation/LiberationSerif-Regular.ttf", },
-        { "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf",
-          "/usr/share/fonts/dejavu/DejaVuSans.ttf", },
-        { "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf",
-          "/usr/share/fonts/dejavu/DejaVuSerif.ttf", },
+    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"
+    };
 
+    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.
-        { "/usr/share/fonts/opentype/stix/STIXGeneral.otf",
-          "/usr/share/fonts/stix/STIXGeneral.otf" },
-        { "/usr/share/fonts/opentype/stix/STIXGeneralBolIta.otf",
-          "/usr/share/fonts/stix/STIXGeneralBolIta.otf" },
-        { "/usr/share/fonts/opentype/stix/STIXGeneralBol.otf",
-          "/usr/share/fonts/stix/STIXGeneralBol.otf" },
-        { "/usr/share/fonts/opentype/stix/STIXGeneralItalic.otf",
-          "/usr/share/fonts/stix/STIXGeneralItalic.otf" }
+        "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 < 2; path++) {
-            if (!g_file_test(fontPaths[font][path], G_FILE_TEST_EXISTS))
-                continue;
-
-            found = true;
-            if (!FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(fontPaths[font][path])))
-                g_error("Could not load font at %s!", fontPaths[font][path]);
-            else
-                break;
+        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) {
-            g_error("Could not find font at %s. Either install this font or file a bug "
+            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][0]);
+                    fontPaths[font], directoriesDescription.get());
         }
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to