Changeset 121684 in webkit


Ignore:
Timestamp:
Jul 2, 2012 9:10:49 AM (12 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Read fonts path when running layout tests from alternative fonts dir when main dir doesn't exist
https://bugs.webkit.org/show_bug.cgi?id=89437

Reviewed by Martin Robinson.

If main fonts directory doesn't exist, try with an alternative
fonts directory at build directory.

  • DumpRenderTree/gtk/DumpRenderTree.cpp:

(getOutputDir):
(getFontsPath):
(initializeFonts):

  • WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp:

(WTR::getOutputDir):
(WTR):
(WTR::getFontsPath):
(WTR::inititializeFontConfigSetting):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r121681 r121684  
     12012-07-02  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Read fonts path when running layout tests from alternative fonts dir when main dir doesn't exist
     4        https://bugs.webkit.org/show_bug.cgi?id=89437
     5
     6        Reviewed by Martin Robinson.
     7
     8        If main fonts directory doesn't exist, try with an alternative
     9        fonts directory at build directory.
     10
     11        * DumpRenderTree/gtk/DumpRenderTree.cpp:
     12        (getOutputDir):
     13        (getFontsPath):
     14        (initializeFonts):
     15        * WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp:
     16        (WTR::getOutputDir):
     17        (WTR):
     18        (WTR::getFontsPath):
     19        (WTR::inititializeFontConfigSetting):
     20
    1212012-07-02  Carlos Garcia Campos  <cgarcia@igalia.com>
    222
  • trunk/Tools/DumpRenderTree/gtk/DumpRenderTree.cpp

    r121568 r121684  
    170170}
    171171
     172CString getOutputDir()
     173{
     174    const char* webkitOutputDir = g_getenv("WEBKITOUTPUTDIR");
     175    if (webkitOutputDir)
     176        return webkitOutputDir;
     177
     178    CString topLevelPath = getTopLevelPath();
     179    GOwnPtr<char> outputDir(g_build_filename(topLevelPath.data(), "WebKitBuild", NULL));
     180    return outputDir.get();
     181}
     182
     183static CString getFontsPath()
     184{
     185    CString webkitOutputDir = getOutputDir();
     186    GOwnPtr<char> fontsPath(g_build_filename(webkitOutputDir.data(), "Dependencies", "Root", "webkitgtk-test-fonts", NULL));
     187    if (g_file_test(fontsPath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
     188        return fontsPath.get();
     189
     190    // Try alternative fonts path.
     191    fontsPath.set(g_build_filename(webkitOutputDir.data(), "webkitgtk-test-fonts", NULL));
     192    if (g_file_test(fontsPath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
     193        return fontsPath.get();
     194
     195    return CString();
     196}
     197
    172198static void initializeFonts(const char* testURL = 0)
    173199{
     
    191217        g_error("Couldn't load font configuration file from: %s", fontConfigFilename.get());
    192218
    193     GOwnPtr<char> fontsPath;
    194     const char* webkitOutputDir = g_getenv("WEBKITOUTPUTDIR");
    195     if (webkitOutputDir)
    196         fontsPath.set(g_build_filename(webkitOutputDir, "Dependencies", "Root", "webkitgtk-test-fonts", NULL));
    197     else {
    198         CString topLevelPath = getTopLevelPath();
    199         fontsPath.set(g_build_filename(topLevelPath.data(), "WebKitBuild", "Dependencies", "Root", "webkitgtk-test-fonts", NULL));
    200     }
    201 
    202     if (!g_file_test(fontsPath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
    203         g_error("Could not locate test fonts at %s. Is WEBKIT_TOP_LEVEL set?", fontsPath.get());
     219    CString fontsPath = getFontsPath();
     220    if (fontsPath.isNull())
     221        g_error("Could not locate test fonts at %s. Is WEBKIT_TOP_LEVEL set?", fontsPath.data());
    204222
    205223    GOwnPtr<GError> error;
    206     GOwnPtr<GDir> fontsDirectory(g_dir_open(fontsPath.get(), 0, &error.outPtr()));
     224    GOwnPtr<GDir> fontsDirectory(g_dir_open(fontsPath.data(), 0, &error.outPtr()));
    207225    while (const char* directoryEntry = g_dir_read_name(fontsDirectory.get())) {
    208226        if (!g_str_has_suffix(directoryEntry, ".ttf") && !g_str_has_suffix(directoryEntry, ".otf"))
    209227            continue;
    210         GOwnPtr<gchar> fontPath(g_build_filename(fontsPath.get(), directoryEntry, NULL));
     228        GOwnPtr<gchar> fontPath(g_build_filename(fontsPath.data(), directoryEntry, NULL));
    211229        if (!FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(fontPath.get())))
    212230            g_error("Could not load font at %s!", fontPath.get());
  • trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/ActivateFontsGtk.cpp

    r121499 r121684  
    6767}
    6868
     69CString getOutputDir()
     70{
     71    const char* webkitOutputDir = g_getenv("WEBKITOUTPUTDIR");
     72    if (webkitOutputDir)
     73        return webkitOutputDir;
     74
     75    CString topLevelPath = getTopLevelPath();
     76    GOwnPtr<char> outputDir(g_build_filename(topLevelPath.data(), "WebKitBuild", NULL));
     77    return outputDir.get();
     78}
     79
     80static CString getFontsPath()
     81{
     82    CString webkitOutputDir = getOutputDir();
     83    GOwnPtr<char> fontsPath(g_build_filename(webkitOutputDir.data(), "Dependencies", "Root", "webkitgtk-test-fonts", NULL));
     84    if (g_file_test(fontsPath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
     85        return fontsPath.get();
     86
     87    // Try alternative fonts path.
     88    fontsPath.set(g_build_filename(webkitOutputDir.data(), "webkitgtk-test-fonts", NULL));
     89    if (g_file_test(fontsPath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
     90        return fontsPath.get();
     91
     92    return CString();
     93}
     94
    6995void inititializeFontConfigSetting()
    7096{
     
    87113        g_error("Couldn't load font configuration file from: %s", fontConfigFilename.get());
    88114
    89     GOwnPtr<char> fontsPath;
    90     const char* webkitOutputDir = g_getenv("WEBKITOUTPUTDIR");
    91     if (webkitOutputDir)
    92         fontsPath.set(g_build_filename(webkitOutputDir, "Dependencies", "Root", "webkitgtk-test-fonts", NULL));
    93     else {
    94         CString topLevelPath = getTopLevelPath();
    95         fontsPath.set(g_build_filename(topLevelPath.data(), "WebKitBuild", "Dependencies", "Root", "webkitgtk-test-fonts", NULL));
    96     }
    97 
    98     if (!g_file_test(fontsPath.get(), static_cast<GFileTest>(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
    99         g_error("Could not locate test fonts at %s. Is WEBKIT_TOP_LEVEL set?", fontsPath.get());
     115    CString fontsPath = getFontsPath();
     116    if (fontsPath.isNull())
     117        g_error("Could not locate test fonts at %s. Is WEBKIT_TOP_LEVEL set?", fontsPath.data());
    100118
    101119    GOwnPtr<GError> error;
    102     GOwnPtr<GDir> fontsDirectory(g_dir_open(fontsPath.get(), 0, &error.outPtr()));
     120    GOwnPtr<GDir> fontsDirectory(g_dir_open(fontsPath.data(), 0, &error.outPtr()));
    103121    while (const char* directoryEntry = g_dir_read_name(fontsDirectory.get())) {
    104122        if (!g_str_has_suffix(directoryEntry, ".ttf") && !g_str_has_suffix(directoryEntry, ".otf"))
    105123            continue;
    106         GOwnPtr<gchar> fontPath(g_build_filename(fontsPath.get(), directoryEntry, NULL));
     124        GOwnPtr<gchar> fontPath(g_build_filename(fontsPath.data(), directoryEntry, NULL));
    107125        if (!FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(fontPath.get())))
    108126            g_error("Could not load font at %s!", fontPath.get());
Note: See TracChangeset for help on using the changeset viewer.