Changeset 222800 in webkit


Ignore:
Timestamp:
Oct 3, 2017 12:21:19 PM (7 years ago)
Author:
Adrian Perez de Castro
Message:

[GTK] Support the "system" CSS font family
https://bugs.webkit.org/show_bug.cgi?id=177755

Reviewed by Carlos Garcia Campos.

Obtain the system UI font from the GtkSettings::gtk-font-name property

Source/WebCore:

Test: platform/gtk/fonts/systemFont.html

  • platform/graphics/freetype/FontCacheFreeType.cpp:

(WebCore::getFamilyNameStringFromFamily): Use defaultGtkSystemFont()
to handle -webkit-system-font and -webkit-system-ui.
(WebCore::isCommonlyUsedGenericFamily): Handle -webkit-system-font and
-webkit-system-ui as generic family names.

  • platform/graphics/gtk/GtkUtilities.cpp:

(WebCore::defaultGtkSystemFont): Added.

  • platform/graphics/gtk/GtkUtilities.h: Add prototype for defaultGtkSystemFont().

LayoutTests:

  • platform/gtk/fonts/systemFont-expected.html: Added.
  • platform/gtk/fonts/systemFont.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r222795 r222800  
     12017-10-03  Adrian Perez de Castro  <aperez@igalia.com>
     2
     3        [GTK] Support the "system" CSS font family
     4        https://bugs.webkit.org/show_bug.cgi?id=177755
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Obtain the system UI font from the GtkSettings::gtk-font-name property
     9
     10        * platform/gtk/fonts/systemFont-expected.html: Added.
     11        * platform/gtk/fonts/systemFont.html: Added.
     12
    1132017-10-03  Daniel Bates  <dabates@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r222795 r222800  
     12017-10-03  Adrian Perez de Castro  <aperez@igalia.com>
     2
     3        [GTK] Support the "system" CSS font family
     4        https://bugs.webkit.org/show_bug.cgi?id=177755
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Obtain the system UI font from the GtkSettings::gtk-font-name property
     9
     10        Test: platform/gtk/fonts/systemFont.html
     11
     12        * platform/graphics/freetype/FontCacheFreeType.cpp:
     13        (WebCore::getFamilyNameStringFromFamily): Use defaultGtkSystemFont()
     14        to handle -webkit-system-font and -webkit-system-ui.
     15        (WebCore::isCommonlyUsedGenericFamily): Handle -webkit-system-font and
     16        -webkit-system-ui as generic family names.
     17        * platform/graphics/gtk/GtkUtilities.cpp:
     18        (WebCore::defaultGtkSystemFont): Added.
     19        * platform/graphics/gtk/GtkUtilities.h: Add prototype for defaultGtkSystemFont().
     20
    1212017-10-03  Daniel Bates  <dabates@apple.com>
    222
  • trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp

    r219418 r222800  
    3434#include <wtf/text/CString.h>
    3535
     36#if PLATFORM(GTK)
     37#include "GtkUtilities.h"
     38#endif
     39
    3640namespace WebCore {
    3741
     
    158162    if (family == fantasyFamily)
    159163        return "fantasy";
     164
     165#if PLATFORM(GTK)
     166    if (family == systemUiFamily || family == "-webkit-system-font")
     167        return defaultGtkSystemFont();
     168#endif
     169
    160170    return "";
    161171}
     
    317327        || equalLettersIgnoringASCIICase(familyNameString, "monospace")
    318328        || equalLettersIgnoringASCIICase(familyNameString, "fantasy")
     329#if PLATFORM(GTK)
     330        || equalLettersIgnoringASCIICase(familyNameString, "-webkit-system-font")
     331        || equalLettersIgnoringASCIICase(familyNameString, "-webkit-system-ui")
     332#endif
    319333        || equalLettersIgnoringASCIICase(familyNameString, "cursive");
    320334}
  • trunk/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.cpp

    r219595 r222800  
    3434#include <mutex>
    3535#include <wtf/NeverDestroyed.h>
     36#include <wtf/glib/GUniquePtr.h>
    3637
    3738namespace WebCore {
  • trunk/Source/WebCore/platform/gtk/GtkUtilities.cpp

    r222776 r222800  
    6565}
    6666
     67String defaultGtkSystemFont()
     68{
     69    GUniqueOutPtr<char> fontString;
     70    g_object_get(gtk_settings_get_default(), "gtk-font-name", &fontString.outPtr(), nullptr);
     71    // We need to remove the size from the value of the property,
     72    // which is separated from the font family using a space.
     73    if (auto* spaceChar = strrchr(fontString.get(), ' '))
     74        *spaceChar = '\0';
     75    return String::fromUTF8(fontString.get());
     76}
     77
    6778#if ENABLE(DEVELOPER_MODE)
    6879static CString topLevelPath()
  • trunk/Source/WebCore/platform/gtk/GtkUtilities.h

    r222776 r222800  
    2323#include <wtf/WallTime.h>
    2424#include <wtf/text/CString.h>
     25#include <wtf/text/WTFString.h>
    2526
    2627namespace WebCore {
     
    3738WallTime wallTimeForEvent(const GdkEvent*);
    3839
     40String defaultGtkSystemFont();
     41
    3942#if ENABLE(DEVELOPER_MODE)
    4043CString webkitBuildDirectory();
Note: See TracChangeset for help on using the changeset viewer.