Changeset 214785 in webkit


Ignore:
Timestamp:
Apr 3, 2017 6:07:59 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r214283 - [GTK] Honor GTK+ font settings
https://bugs.webkit.org/show_bug.cgi?id=82889

Reviewed by Carlos Garcia Campos.

After much discussion with Behdad and Martin (who is still not completely convinced I think
:) I want to merge cairo font options into the Fontconfig pattern used for rendering using
cairo_ft_font_options_substitute(). This is how the API was designed to be used anyway.
Fontconfig will still have final say over whether to actually respect the desktop settings
or not, so it can still choose to ignore the desktop's settings, but I don't think it makes
sense to have desktop-wide font settings and not tell Fontconfig about them, especially when
the whole point of WebKitGTK+ is desktop integration. This should also reduce complaints
that we're not following desktop settings and that we're drawing fonts differently than
Firefox.

  • PlatformGTK.cmake:
  • platform/graphics/cairo/CairoUtilities.cpp:

(WebCore::getDefaultCairoFontOptions):

  • platform/graphics/cairo/CairoUtilities.h:
  • platform/graphics/freetype/FontCacheFreeType.cpp:

(WebCore::createFontConfigPatternForCharacters):
(WebCore::strongAliasesForFamily):
(WebCore::FontCache::createFontPlatformData):

  • platform/graphics/freetype/FontPlatformDataFreeType.cpp:

(WebCore::getDefaultFontconfigOptions):
(WebCore::getDefaultCairoFontOptions): Deleted.

  • platform/graphics/gtk/GdkCairoUtilities.cpp:

(getDefaultCairoFontOptions):

Location:
releases/WebKitGTK/webkit-2.16/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog

    r214783 r214785  
     12017-03-22  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [GTK] Honor GTK+ font settings
     4        https://bugs.webkit.org/show_bug.cgi?id=82889
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        After much discussion with Behdad and Martin (who is still not completely convinced I think
     9        :) I want to merge cairo font options into the Fontconfig pattern used for rendering using
     10        cairo_ft_font_options_substitute(). This is how the API was designed to be used anyway.
     11        Fontconfig will still have final say over whether to actually respect the desktop settings
     12        or not, so it can still choose to ignore the desktop's settings, but I don't think it makes
     13        sense to have desktop-wide font settings and not tell Fontconfig about them, especially when
     14        the whole point of WebKitGTK+ is desktop integration. This should also reduce complaints
     15        that we're not following desktop settings and that we're drawing fonts differently than
     16        Firefox.
     17
     18        * PlatformGTK.cmake:
     19        * platform/graphics/cairo/CairoUtilities.cpp:
     20        (WebCore::getDefaultCairoFontOptions):
     21        * platform/graphics/cairo/CairoUtilities.h:
     22        * platform/graphics/freetype/FontCacheFreeType.cpp:
     23        (WebCore::createFontConfigPatternForCharacters):
     24        (WebCore::strongAliasesForFamily):
     25        (WebCore::FontCache::createFontPlatformData):
     26        * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
     27        (WebCore::getDefaultFontconfigOptions):
     28        (WebCore::getDefaultCairoFontOptions): Deleted.
     29        * platform/graphics/gtk/GdkCairoUtilities.cpp:
     30        (getDefaultCairoFontOptions):
     31
    1322017-03-22  Chris Dumez  <cdumez@apple.com>
    233
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/PlatformGTK.cmake

    r211836 r214785  
    113113    platform/graphics/freetype/FontCacheFreeType.cpp
    114114    platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
     115    platform/graphics/freetype/FontPlatformDataFreeType.cpp
    115116    platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp
    116117    platform/graphics/freetype/SimpleFontDataFreeType.cpp
     
    187188
    188189    platform/graphics/PlatformDisplay.cpp
    189 
    190     platform/graphics/freetype/FontPlatformDataFreeType.cpp
    191190
    192191    platform/graphics/gtk/ColorGtk.cpp
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp

    r214763 r214785  
    4040#include "Region.h"
    4141#include <wtf/Assertions.h>
     42#include <wtf/NeverDestroyed.h>
    4243#include <wtf/Vector.h>
    4344
     
    4748
    4849namespace WebCore {
     50
     51#if USE(FREETYPE) && !PLATFORM(GTK)
     52const cairo_font_options_t* getDefaultCairoFontOptions()
     53{
     54    static NeverDestroyed<cairo_font_options_t*> options = cairo_font_options_create();
     55    return options;
     56}
     57#endif
    4958
    5059void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr)
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/cairo/CairoUtilities.h

    r214763 r214785  
    2525 */
    2626
    27 #ifndef CairoUtilities_h
    28 #define CairoUtilities_h
     27#pragma once
    2928
    3029#if USE(CAIRO)
     
    7271    FT_Face m_ftFace { nullptr };
    7372};
     73
     74const cairo_font_options_t* getDefaultCairoFontOptions();
    7475#endif
    7576
     
    9899
    99100#endif // USE(CAIRO)
    100 
    101 #endif // CairoUtilities_h
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp

    r212513 r214785  
    2323#include "FontCache.h"
    2424
     25#include "CairoUtilities.h"
    2526#include "FcUniquePtr.h"
    2627#include "Font.h"
     
    5859    FcPatternAddBool(pattern.get(), FC_SCALABLE, FcTrue);
    5960    FcConfigSubstitute(nullptr, pattern.get(), FcMatchPattern);
     61    cairo_ft_font_options_substitute(getDefaultCairoFontOptions(), pattern.get());
    6062    FcDefaultSubstitute(pattern.get());
    6163    return pattern;
     
    267269
    268270    FcConfigSubstitute(nullptr, pattern.get(), FcMatchPattern);
     271    cairo_ft_font_options_substitute(getDefaultCairoFontOptions(), pattern.get());
    269272    FcDefaultSubstitute(pattern.get());
    270273
     
    361364    // since this is an exact matter of respecting the user's font configuration.
    362365    FcConfigSubstitute(nullptr, pattern.get(), FcMatchPattern);
     366    cairo_ft_font_options_substitute(getDefaultCairoFontOptions(), pattern.get());
    363367    FcDefaultSubstitute(pattern.get());
    364368
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp

    r211029 r214785  
    3838#include <wtf/text/WTFString.h>
    3939
    40 #if PLATFORM(GTK)
    41 #include <gdk/gdk.h>
    42 #endif
    43 
    4440namespace WebCore {
    4541
     
    107103}
    108104
    109 static CairoUniquePtr<cairo_font_options_t> getDefaultCairoFontOptions()
    110 {
    111 #if PLATFORM(GTK)
    112     if (GdkScreen* screen = gdk_screen_get_default()) {
    113         const cairo_font_options_t* screenOptions = gdk_screen_get_font_options(screen);
    114         if (screenOptions)
    115             return CairoUniquePtr<cairo_font_options_t>(cairo_font_options_copy(screenOptions));
    116     }
    117 #endif
    118     return CairoUniquePtr<cairo_font_options_t>(cairo_font_options_create());
    119 }
    120 
    121105static FcPattern* getDefaultFontconfigOptions()
    122106{
     
    130114        pattern = FcPatternCreate();
    131115        FcConfigSubstitute(nullptr, pattern, FcMatchPattern);
     116        cairo_ft_font_options_substitute(getDefaultCairoFontOptions(), pattern);
    132117        FcDefaultSubstitute(pattern);
    133118        FcPatternDel(pattern, FC_FAMILY);
     
    306291void FontPlatformData::buildScaledFont(cairo_font_face_t* fontFace)
    307292{
    308     CairoUniquePtr<cairo_font_options_t> options = getDefaultCairoFontOptions();
     293    CairoUniquePtr<cairo_font_options_t> options(cairo_font_options_copy(getDefaultCairoFontOptions()));
    309294    FcPattern* optionsPattern = m_pattern ? m_pattern.get() : getDefaultFontconfigOptions();
    310295    setCairoFontOptionsFromFontConfigPattern(options.get(), optionsPattern);
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.cpp

    r165676 r214785  
    3232#include <cairo.h>
    3333#include <gtk/gtk.h>
     34#include <mutex>
     35#include <wtf/NeverDestroyed.h>
    3436
    35 using namespace WebCore;
     37namespace WebCore {
     38
     39const cairo_font_options_t* getDefaultCairoFontOptions()
     40{
     41    if (auto* screen = gdk_screen_get_default()) {
     42        if (auto* options = gdk_screen_get_font_options(screen))
     43            return options;
     44    }
     45
     46    static LazyNeverDestroyed<cairo_font_options_t*> options;
     47    static std::once_flag flag;
     48    std::call_once(flag, [] {
     49        options.construct(cairo_font_options_create());
     50    });
     51    return options;
     52}
    3653
    3754GdkPixbuf* cairoSurfaceToGdkPixbuf(cairo_surface_t* surface)
     
    4158}
    4259
     60}
  • releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/graphics/gtk/GdkCairoUtilities.h

    r165676 r214785  
    2424 */
    2525
    26 #ifndef GdkCairoUtilities_h
    27 #define GdkCairoUtilities_h
     26#pragma once
     27
     28namespace WebCore {
    2829
    2930GdkPixbuf* cairoSurfaceToGdkPixbuf(cairo_surface_t*);
    3031
    31 #endif // GdkCairoUtilities_h
     32}
Note: See TracChangeset for help on using the changeset viewer.