Changeset 68558 in webkit


Ignore:
Timestamp:
Sep 28, 2010 1:45:44 PM (14 years ago)
Author:
Martin Robinson
Message:

2010-09-28 Martin Robinson <mrobinson@igalia.com>

Reviewed by Gustavo Noronha Silva.

[Cairo] FreeType fonts should obey FontConfig hinting/anti-aliasing settings
https://bugs.webkit.org/show_bug.cgi?id=46740

Added a test adapted from platform/chromium/fast/text/chromium-linux-fontconfig-renderstyle.html
which verifies that when rendering text the GTK+ port follows FontConfig settings.

  • platform/gtk/fonts/fontconfig-aliasing-settings-expected.checksum: Added.
  • platform/gtk/fonts/fontconfig-aliasing-settings-expected.png: Added.
  • platform/gtk/fonts/fontconfig-aliasing-settings-expected.txt: Added.
  • platform/gtk/fonts/fontconfig-aliasing-settings.html: Added.

2010-09-28 Martin Robinson <mrobinson@igalia.com>

Reviewed by Gustavo Noronha Silva.

[Cairo] FreeType fonts should obey FontConfig hinting/anti-aliasing settings
https://bugs.webkit.org/show_bug.cgi?id=46740

When creating a font from a FontConfig pattern, use the FontConfig pattern's
hinting and anti-aliasing settings. This follows the Chromium Linux approach
of having FontConfig settings take precedence over GTK+ settings, as GTK+
settings cannot be configured per-font and per-font-size.

Test: platform/gtk/fonts/fontconfig-aliasing-settings.html

  • platform/graphics/cairo/FontPlatformDataFreeType.cpp: (WebCore::convertFontConfigSubpixelOrder): Added this helper which converts the FontConfig subpixel order into the cairo equivalent. (WebCore::convertFontConfigHintStyle): Added this helper which converts the FontConfig hint style into the cairo equivalent. (WebCore::setCairoFontOptionsFromFontConfigPattern): Added this helper which reads the font rendering settings from a pattern and translates them into the appropriate cairo_font_options_t settings. (WebCore::FontPlatformData::FontPlatformData): When creating a font from a FontConfig pattern use setCairoFontOptionsFromFontConfigPattern to get the appropriate rendering options for the font.

2010-09-28 Martin Robinson <mrobinson@igalia.com>

Reviewed by Gustavo Noronha Silva.

[Cairo] FreeType fonts should obey FontConfig hinting/anti-aliasing settings
https://bugs.webkit.org/show_bug.cgi?id=46740

  • DumpRenderTree/gtk/fonts/fonts.conf: Add specialized variants of common fonts which can be used to fully test FontConfig rendering settings.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r68555 r68558  
     12010-09-28  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Gustavo Noronha Silva.
     4
     5        [Cairo] FreeType fonts should obey FontConfig hinting/anti-aliasing settings
     6        https://bugs.webkit.org/show_bug.cgi?id=46740
     7
     8        Added a test adapted from platform/chromium/fast/text/chromium-linux-fontconfig-renderstyle.html
     9        which verifies that when rendering text the GTK+ port follows FontConfig settings.
     10
     11        * platform/gtk/fonts/fontconfig-aliasing-settings-expected.checksum: Added.
     12        * platform/gtk/fonts/fontconfig-aliasing-settings-expected.png: Added.
     13        * platform/gtk/fonts/fontconfig-aliasing-settings-expected.txt: Added.
     14        * platform/gtk/fonts/fontconfig-aliasing-settings.html: Added.
     15
    1162010-09-28  Dan Bernstein  <mitz@apple.com>
    217
  • trunk/WebCore/ChangeLog

    r68557 r68558  
     12010-09-28  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Gustavo Noronha Silva.
     4
     5        [Cairo] FreeType fonts should obey FontConfig hinting/anti-aliasing settings
     6        https://bugs.webkit.org/show_bug.cgi?id=46740
     7
     8        When creating a font from a FontConfig pattern, use the FontConfig pattern's
     9        hinting and anti-aliasing settings. This follows the Chromium Linux approach
     10        of having FontConfig settings take precedence over GTK+ settings, as GTK+
     11        settings cannot be configured per-font and per-font-size.
     12
     13        Test: platform/gtk/fonts/fontconfig-aliasing-settings.html
     14
     15        * platform/graphics/cairo/FontPlatformDataFreeType.cpp:
     16        (WebCore::convertFontConfigSubpixelOrder): Added this helper which converts
     17        the FontConfig subpixel order into the cairo equivalent.
     18        (WebCore::convertFontConfigHintStyle): Added this helper which converts the
     19        FontConfig hint style into the cairo equivalent.
     20        (WebCore::setCairoFontOptionsFromFontConfigPattern): Added this helper which
     21        reads the font rendering settings from a pattern and translates them into the
     22        appropriate cairo_font_options_t settings.
     23        (WebCore::FontPlatformData::FontPlatformData): When creating a font from a
     24        FontConfig pattern use setCairoFontOptionsFromFontConfigPattern to get the
     25        appropriate rendering options for the font.
     26
    1272010-09-28  Sam Weinig  <sam@webkit.org>
    228
  • trunk/WebCore/platform/graphics/cairo/FontPlatformDataFreeType.cpp

    r68406 r68558  
    3838namespace WebCore {
    3939
     40cairo_subpixel_order_t convertFontConfigSubpixelOrder(int fontConfigOrder)
     41{
     42    switch (fontConfigOrder) {
     43    case FC_RGBA_RGB:
     44        return CAIRO_SUBPIXEL_ORDER_RGB;
     45    case FC_RGBA_BGR:
     46        return CAIRO_SUBPIXEL_ORDER_BGR;
     47    case FC_RGBA_VRGB:
     48        return CAIRO_SUBPIXEL_ORDER_VRGB;
     49    case FC_RGBA_VBGR:
     50        return CAIRO_SUBPIXEL_ORDER_VBGR;
     51    case FC_RGBA_NONE:
     52    case FC_RGBA_UNKNOWN:
     53        return CAIRO_SUBPIXEL_ORDER_DEFAULT;
     54    }
     55    return CAIRO_SUBPIXEL_ORDER_DEFAULT;
     56}
     57
     58cairo_hint_style_t convertFontConfigHintStyle(int fontConfigStyle)
     59{
     60    switch (fontConfigStyle) {
     61    case FC_HINT_NONE:
     62        return CAIRO_HINT_STYLE_NONE;
     63    case FC_HINT_SLIGHT:
     64        return CAIRO_HINT_STYLE_SLIGHT;
     65    case FC_HINT_MEDIUM:
     66        return CAIRO_HINT_STYLE_MEDIUM;
     67    case FC_HINT_FULL:
     68        return CAIRO_HINT_STYLE_FULL;
     69    }
     70    return CAIRO_HINT_STYLE_NONE;
     71}
     72
     73void setCairoFontOptionsFromFontConfigPattern(cairo_font_options_t* options, FcPattern* pattern)
     74{
     75    FcBool booleanResult;
     76    int integerResult;
     77
     78    // We will determine if subpixel anti-aliasing is enabled via the FC_RGBA setting.
     79    if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &booleanResult) == FcResultMatch && booleanResult)
     80        cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
     81
     82    if (FcPatternGetInteger(pattern, FC_RGBA, 0, &integerResult) == FcResultMatch) {
     83        if (integerResult != FC_RGBA_NONE)
     84            cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_SUBPIXEL);
     85        cairo_font_options_set_subpixel_order(options, convertFontConfigSubpixelOrder(integerResult));
     86    }
     87
     88    if (FcPatternGetInteger(pattern, FC_HINT_STYLE, 0, &integerResult) == FcResultMatch)
     89        cairo_font_options_set_hint_style(options, convertFontConfigHintStyle(integerResult));
     90
     91    if (FcPatternGetBool(pattern, FC_HINTING, 0, &booleanResult) == FcResultMatch && !booleanResult)
     92        cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
     93}
     94
    4095FontPlatformData::FontPlatformData(FcPattern* pattern, const FontDescription& fontDescription)
    4196    : m_pattern(pattern)
     
    45100    , m_syntheticOblique(false)
    46101{
    47     // FIXME: We should be getting these options from FontConfig.
    48     static const cairo_font_options_t* defaultOptions = cairo_font_options_create();
    49     const cairo_font_options_t* options = 0;
    50 #if !PLATFORM(EFL) || ENABLE(GLIB_SUPPORT)
    51     if (GdkScreen* screen = gdk_screen_get_default())
    52         options = gdk_screen_get_font_options(screen);
    53 #endif
    54     // gdk_screen_get_font_options() returns null if no default options are
    55     // set, so we always have to check.
    56     if (!options)
    57         options = defaultOptions;
     102    cairo_font_options_t* options = cairo_font_options_create();
     103    setCairoFontOptionsFromFontConfigPattern(options, pattern);
    58104
    59105    cairo_matrix_t fontMatrix;
  • trunk/WebKitTools/ChangeLog

    r68554 r68558  
     12010-09-28  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by Gustavo Noronha Silva.
     4
     5        [Cairo] FreeType fonts should obey FontConfig hinting/anti-aliasing settings
     6        https://bugs.webkit.org/show_bug.cgi?id=46740
     7
     8        * DumpRenderTree/gtk/fonts/fonts.conf: Add specialized variants of common
     9        fonts which can be used to fully test FontConfig rendering settings.
     10
    1112010-09-28  Martin Robinson  <mrobinson@igalia.com>
    212
  • trunk/WebKitTools/DumpRenderTree/gtk/fonts/fonts.conf

    r68403 r68558  
    100100        <string>Liberation Mono</string>
    101101      </edit>
     102    </match>
     103
     104    <!-- The following hinting specializations are adapted from those in the
     105         Chromium test_shell.  We try to duplicate their incredibly thorough
     106         testing here -->
     107    <match target="pattern">
     108        <test name="family" compare="eq">
     109            <string>NonAntiAliasedSans</string>
     110        </test>
     111        <edit name="family" mode="assign">
     112            <string>Liberation Sans</string>
     113        </edit>
     114        <edit name="antialias" mode="assign">
     115            <bool>false</bool>
     116        </edit>
     117    </match>
     118   
     119    <match target="pattern">
     120        <test name="family" compare="eq">
     121            <string>SlightHintedSerif</string>
     122        </test>
     123        <edit name="family" mode="assign">
     124            <string>Liberation Serif</string>
     125        </edit>
     126        <edit name="hintstyle" mode="assign">
     127            <const>hintslight</const>
     128        </edit>
     129    </match>
     130   
     131    <match target="pattern">
     132        <test name="family" compare="eq">
     133            <string>NonHintedSans</string>
     134        </test>
     135        <edit name="family" mode="assign">
     136            <string>Liberation Sans</string>
     137        </edit>
     138        <!-- These deliberately contradict each other. The 'hinting' preference
     139             should take priority -->
     140        <edit name="hintstyle" mode="assign">
     141            <const>hintfull</const>
     142        </edit>
     143     <edit name="hinting" mode="assign">
     144            <bool>false</bool>
     145        </edit>
     146    </match>
     147   
     148    <match target="pattern">
     149        <test name="family" compare="eq">
     150            <string>AutohintedSerif</string>
     151        </test>
     152        <edit name="family" mode="assign">
     153            <string>Liberation Serif</string>
     154        </edit>
     155        <edit name="autohint" mode="assign">
     156            <bool>true</bool>
     157        </edit>
     158        <edit name="hintstyle" mode="assign">
     159            <const>hintmedium</const>
     160        </edit>
     161    </match>
     162   
     163    <match target="pattern">
     164        <test name="family" compare="eq">
     165            <string>HintedSerif</string>
     166        </test>
     167        <edit name="family" mode="assign">
     168            <string>Liberation Serif</string>
     169        </edit>
     170        <edit name="autohint" mode="assign">
     171            <bool>false</bool>
     172        </edit>
     173        <edit name="hintstyle" mode="assign">
     174            <const>hintmedium</const>
     175        </edit>
     176    </match>
     177   
     178    <match target="pattern">
     179        <test name="family" compare="eq">
     180            <string>FullAndAutoHintedSerif</string>
     181        </test>
     182        <edit name="family" mode="assign">
     183            <string>Liberation Serif</string>
     184        </edit>
     185        <edit name="autohint" mode="assign">
     186            <bool>true</bool>
     187        </edit>
     188        <edit name="hintstyle" mode="assign">
     189            <const>hintfull</const>
     190        </edit>
     191    </match>
     192   
     193    <match target="pattern">
     194        <test name="family" compare="eq">
     195            <string>SubpixelEnabledSans</string>
     196        </test>
     197        <edit name="family" mode="assign">
     198            <string>Liberation Sans</string>
     199        </edit>
     200        <edit name="rgba" mode="assign">
     201            <const>rgb</const>
     202        </edit>
     203    </match>
     204   
     205    <match target="pattern">
     206        <test name="family" compare="eq">
     207            <string>SubpixelDisabledSans</string>
     208        </test>
     209        <edit name="family" mode="assign">
     210            <string>Liberation Sans</string>
     211        </edit>
     212        <edit name="rgba" mode="assign">
     213            <const>none</const>
     214        </edit>
    102215    </match>
    103216
Note: See TracChangeset for help on using the changeset viewer.