Changeset 221670 in webkit


Ignore:
Timestamp:
Sep 6, 2017 8:10:56 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Bump freetype version to 2.8.0
https://bugs.webkit.org/show_bug.cgi?id=176351

Source/WebCore:

Patch by Dominik Röttsches <dominik.rottsches@intel.com> on 2017-09-06
Reviewed by Carlos Alberto Lopez Perez.

Retrieving line spacing info without metrics hinting - FreeType's metric hinting
uses rounding which results in the sum of ascent and descent being larger
than the line height. To work around this without globally disabling font metrics
hinting, I am temporarily creating a new cairo scaled font with metrics hinting
off and retrieving the height values from this one.

  • platform/graphics/freetype/SimpleFontDataFreeType.cpp:

(WebCore::scaledFontWithoutMetricsHinting): New function to clone the existing font, only with metrics hinting
disabled.
(WebCore::Font::platformInit): Get height info from non-metrics hinted font, disable rounding for linespacing.

Tools:

Reviewed by Carlos Alberto Lopez Perez.

Remove the patch we were using since it was reverted upstream.

  • gtk/jhbuild.modules:
  • gtk/patches/freetype6-2.4.11-truetype-font-height-fix.patch: Removed.
Location:
trunk
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r221669 r221670  
     12017-09-06  Dominik Röttsches  <dominik.rottsches@intel.com>
     2
     3        [GTK] Bump freetype version to 2.8.0
     4        https://bugs.webkit.org/show_bug.cgi?id=176351
     5
     6        Reviewed by Carlos Alberto Lopez Perez.
     7
     8        Retrieving line spacing info without metrics hinting - FreeType's metric hinting
     9        uses rounding which results in the sum of ascent and descent being larger
     10        than the line height. To work around this without globally disabling font metrics
     11        hinting, I am temporarily creating a new cairo scaled font with metrics hinting
     12        off and retrieving the height values from this one.
     13
     14        * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
     15        (WebCore::scaledFontWithoutMetricsHinting): New function to clone the existing font, only with metrics hinting
     16        disabled.
     17        (WebCore::Font::platformInit): Get height info from non-metrics hinted font, disable rounding for linespacing.
     18
    1192017-09-06  Frédéric Wang  <fwang@igalia.com>
    220
  • trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp

    r216896 r221670  
    3434#include "Font.h"
    3535
     36#include "CairoUniquePtr.h"
    3637#include "CairoUtilities.h"
    3738#include "FloatConversion.h"
     
    4142#include "GlyphBuffer.h"
    4243#include "OpenTypeTypes.h"
     44#include "RefPtrCairo.h"
    4345#include "UTF16UChar32Iterator.h"
    4446#include <cairo-ft.h>
     
    5355namespace WebCore {
    5456
     57static RefPtr<cairo_scaled_font_t> scaledFontWithoutMetricsHinting(cairo_scaled_font_t* scaledFont)
     58{
     59    CairoUniquePtr<cairo_font_options_t> fontOptions(cairo_font_options_create());
     60    cairo_scaled_font_get_font_options(scaledFont, fontOptions.get());
     61    cairo_font_options_set_hint_metrics(fontOptions.get(), CAIRO_HINT_METRICS_OFF);
     62    cairo_matrix_t fontMatrix;
     63    cairo_scaled_font_get_font_matrix(scaledFont, &fontMatrix);
     64    cairo_matrix_t fontCTM;
     65    cairo_scaled_font_get_ctm(scaledFont, &fontCTM);
     66    return adoptRef(cairo_scaled_font_create(cairo_scaled_font_get_font_face(scaledFont), &fontMatrix, &fontCTM, fontOptions.get()));
     67}
     68
    5569void Font::platformInit()
    5670{
     
    5973
    6074    ASSERT(m_platformData.scaledFont());
     75    // Temporarily create a clone that doesn't have metrics hinting in order to avoid incorrect
     76    // rounding resulting in incorrect baseline positioning since the sum of ascent and descent
     77    // becomes larger than the line height.
     78    auto fontWithoutMetricsHinting = scaledFontWithoutMetricsHinting(m_platformData.scaledFont());
    6179    cairo_font_extents_t fontExtents;
    62     cairo_scaled_font_extents(m_platformData.scaledFont(), &fontExtents);
     80    cairo_scaled_font_extents(fontWithoutMetricsHinting.get(), &fontExtents);
    6381
    6482    float ascent = narrowPrecisionToFloat(fontExtents.ascent);
     
    89107    m_fontMetrics.setDescent(descent);
    90108    m_fontMetrics.setCapHeight(capHeight);
    91 
    92     // Match CoreGraphics metrics.
    93     m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
     109    m_fontMetrics.setLineSpacing(ascent + descent + lineGap);
    94110    m_fontMetrics.setLineGap(lineGap);
    95111
  • trunk/Tools/ChangeLog

    r221666 r221670  
     12017-09-06  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Bump freetype version to 2.8.0
     4        https://bugs.webkit.org/show_bug.cgi?id=176351
     5
     6        Reviewed by Carlos Alberto Lopez Perez.
     7
     8        Remove the patch we were using since it was reverted upstream.
     9
     10        * gtk/jhbuild.modules:
     11        * gtk/patches/freetype6-2.4.11-truetype-font-height-fix.patch: Removed.
     12
    1132017-09-06  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
    214
  • trunk/Tools/gtk/jhbuild.modules

    r221371 r221670  
    120120
    121121  <autotools id="freetype6" autogen-sh="configure">
    122     <branch module="freetype/freetype-2.4.11.tar.bz2" version="2.4.11"
     122    <branch module="freetype/freetype-2.8.tar.bz2" version="2.8"
    123123            repo="savannah.gnu.org"
    124             hash="sha256:ef9d0bcb64647d9e5125dc7534d7ca371c98310fec87677c410f397f71ffbe3f"
    125             md5sum="b93435488942486c8d0ca22e8f768034">
    126       <patch file="freetype6-2.4.11-truetype-font-height-fix.patch" strip="1"/>
    127     </branch>
     124            hash="sha256:a3c603ed84c3c2495f9c9331fe6bba3bb0ee65e06ec331e0a0fb52158291b40b"/>
    128125  </autotools>
    129126
Note: See TracChangeset for help on using the changeset viewer.