Skip to content

Commit

Permalink
Merge r221670 - [GTK] Bump freetype version to 2.8.0
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Dominik Röttsches authored and carlosgcampos committed Nov 8, 2017
1 parent fa51f6b commit 1db4926
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 46 deletions.
18 changes: 18 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,21 @@
2017-09-06 Dominik Röttsches <dominik.rottsches@intel.com>

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

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.

2017-09-13 Zalan Bujtas <zalan@apple.com>

Switch multicolumn's spanner map from raw over to weak pointers.
Expand Down
Expand Up @@ -33,13 +33,15 @@
#include "config.h"
#include "Font.h"

#include "CairoUniquePtr.h"
#include "CairoUtilities.h"
#include "FloatConversion.h"
#include "FloatRect.h"
#include "FontCache.h"
#include "FontDescription.h"
#include "GlyphBuffer.h"
#include "OpenTypeTypes.h"
#include "RefPtrCairo.h"
#include "UTF16UChar32Iterator.h"
#include <cairo-ft.h>
#include <cairo.h>
Expand All @@ -52,14 +54,30 @@

namespace WebCore {

static RefPtr<cairo_scaled_font_t> scaledFontWithoutMetricsHinting(cairo_scaled_font_t* scaledFont)
{
CairoUniquePtr<cairo_font_options_t> fontOptions(cairo_font_options_create());
cairo_scaled_font_get_font_options(scaledFont, fontOptions.get());
cairo_font_options_set_hint_metrics(fontOptions.get(), CAIRO_HINT_METRICS_OFF);
cairo_matrix_t fontMatrix;
cairo_scaled_font_get_font_matrix(scaledFont, &fontMatrix);
cairo_matrix_t fontCTM;
cairo_scaled_font_get_ctm(scaledFont, &fontCTM);
return adoptRef(cairo_scaled_font_create(cairo_scaled_font_get_font_face(scaledFont), &fontMatrix, &fontCTM, fontOptions.get()));
}

void Font::platformInit()
{
if (!m_platformData.size())
return;

ASSERT(m_platformData.scaledFont());
// Temporarily create a clone that doesn't have metrics hinting in order to avoid incorrect
// rounding resulting in incorrect baseline positioning since the sum of ascent and descent
// becomes larger than the line height.
auto fontWithoutMetricsHinting = scaledFontWithoutMetricsHinting(m_platformData.scaledFont());
cairo_font_extents_t fontExtents;
cairo_scaled_font_extents(m_platformData.scaledFont(), &fontExtents);
cairo_scaled_font_extents(fontWithoutMetricsHinting.get(), &fontExtents);

float ascent = narrowPrecisionToFloat(fontExtents.ascent);
float descent = narrowPrecisionToFloat(fontExtents.descent);
Expand Down Expand Up @@ -88,9 +106,7 @@ void Font::platformInit()
m_fontMetrics.setAscent(ascent);
m_fontMetrics.setDescent(descent);
m_fontMetrics.setCapHeight(capHeight);

// Match CoreGraphics metrics.
m_fontMetrics.setLineSpacing(lroundf(ascent) + lroundf(descent) + lroundf(lineGap));
m_fontMetrics.setLineSpacing(ascent + descent + lineGap);
m_fontMetrics.setLineGap(lineGap);

cairo_text_extents_t textExtents;
Expand Down
12 changes: 12 additions & 0 deletions Tools/ChangeLog
@@ -1,3 +1,15 @@
2017-09-06 Carlos Garcia Campos <cgarcia@igalia.com>

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

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.

2017-10-25 Adrian Perez de Castro <aperez@igalia.com>

[WPE] Remove GLib API functions which use Cairo
Expand Down
4 changes: 1 addition & 3 deletions Tools/gtk/jhbuild.modules
Expand Up @@ -127,9 +127,7 @@
<branch module="freetype/freetype-2.4.11.tar.bz2" version="2.4.11"
repo="savannah.gnu.org"
hash="sha256:ef9d0bcb64647d9e5125dc7534d7ca371c98310fec87677c410f397f71ffbe3f"
md5sum="b93435488942486c8d0ca22e8f768034">
<patch file="freetype6-2.4.11-truetype-font-height-fix.patch" strip="1"/>
</branch>
md5sum="b93435488942486c8d0ca22e8f768034"/>
</autotools>

<autotools id="harfbuzz" autogen-sh="configure">
Expand Down
39 changes: 0 additions & 39 deletions Tools/gtk/patches/freetype6-2.4.11-truetype-font-height-fix.patch

This file was deleted.

0 comments on commit 1db4926

Please sign in to comment.