- Revision
- 221670
- Author
- [email protected]
- Date
- 2017-09-06 08:10:56 -0700 (Wed, 06 Sep 2017)
Log 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 <[email protected]> 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.
Modified Paths
Removed Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (221669 => 221670)
--- trunk/Source/WebCore/ChangeLog 2017-09-06 12:42:46 UTC (rev 221669)
+++ trunk/Source/WebCore/ChangeLog 2017-09-06 15:10:56 UTC (rev 221670)
@@ -1,3 +1,21 @@
+2017-09-06 Dominik Röttsches <[email protected]>
+
+ [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-06 Frédéric Wang <[email protected]>
Introduce ScrollingTreeScrollingNodeDelegateIOS to share code between overflow and frame scrolling
Modified: trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp (221669 => 221670)
--- trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2017-09-06 12:42:46 UTC (rev 221669)
+++ trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2017-09-06 15:10:56 UTC (rev 221670)
@@ -33,6 +33,7 @@
#include "config.h"
#include "Font.h"
+#include "CairoUniquePtr.h"
#include "CairoUtilities.h"
#include "FloatConversion.h"
#include "FloatRect.h"
@@ -40,6 +41,7 @@
#include "FontDescription.h"
#include "GlyphBuffer.h"
#include "OpenTypeTypes.h"
+#include "RefPtrCairo.h"
#include "UTF16UChar32Iterator.h"
#include <cairo-ft.h>
#include <cairo.h>
@@ -52,6 +54,18 @@
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())
@@ -58,8 +72,12 @@
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);
@@ -88,9 +106,7 @@
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;
Modified: trunk/Tools/ChangeLog (221669 => 221670)
--- trunk/Tools/ChangeLog 2017-09-06 12:42:46 UTC (rev 221669)
+++ trunk/Tools/ChangeLog 2017-09-06 15:10:56 UTC (rev 221670)
@@ -1,3 +1,15 @@
+2017-09-06 Carlos Garcia Campos <[email protected]>
+
+ [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-09-06 Yoshiaki Jitsukawa <[email protected]>
[Win] Tools/TestWebKitAPI/Tests/WTF/PriorityQueue.cpp fails to compile with MSVC 2015
Modified: trunk/Tools/gtk/jhbuild.modules (221669 => 221670)
--- trunk/Tools/gtk/jhbuild.modules 2017-09-06 12:42:46 UTC (rev 221669)
+++ trunk/Tools/gtk/jhbuild.modules 2017-09-06 15:10:56 UTC (rev 221670)
@@ -119,12 +119,9 @@
</autotools>
<autotools id="freetype6" autogen-sh="configure">
- <branch module="freetype/freetype-2.4.11.tar.bz2" version="2.4.11"
+ <branch module="freetype/freetype-2.8.tar.bz2" version="2.8"
repo="savannah.gnu.org"
- hash="sha256:ef9d0bcb64647d9e5125dc7534d7ca371c98310fec87677c410f397f71ffbe3f"
- md5sum="b93435488942486c8d0ca22e8f768034">
- <patch file="freetype6-2.4.11-truetype-font-height-fix.patch" strip="1"/>
- </branch>
+ hash="sha256:a3c603ed84c3c2495f9c9331fe6bba3bb0ee65e06ec331e0a0fb52158291b40b"/>
</autotools>
<autotools id="harfbuzz" autogen-sh="configure">
Deleted: trunk/Tools/gtk/patches/freetype6-2.4.11-truetype-font-height-fix.patch (221669 => 221670)
--- trunk/Tools/gtk/patches/freetype6-2.4.11-truetype-font-height-fix.patch 2017-09-06 12:42:46 UTC (rev 221669)
+++ trunk/Tools/gtk/patches/freetype6-2.4.11-truetype-font-height-fix.patch 2017-09-06 15:10:56 UTC (rev 221670)
@@ -1,39 +0,0 @@
-From e0469372be3870a5ad60b2c4586e9c281357bd28 Mon Sep 17 00:00:00 2001
-From: Werner Lemberg <[email protected]>
-Date: Tue, 22 Jan 2013 10:07:07 +0000
-Subject: [truetype] Fix font height.
-
-* src/truetype/ttobjs.c (tt_size_reset): The Windows rendering
-engine uses rounded values of the ascender and descender to compute
-the TrueType font height.
----
-diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
-index c61b218..590b66c 100644
---- a/src/truetype/ttobjs.c
-+++ b/src/truetype/ttobjs.c
-@@ -4,7 +4,7 @@
- /* */
- /* Objects manager (body). */
- /* */
--/* Copyright 1996-2012 */
-+/* Copyright 1996-2013 */
- /* David Turner, Robert Wilhelm, and Werner Lemberg. */
- /* */
- /* This file is part of the FreeType project, and may only be used, */
-@@ -1177,11 +1177,12 @@
- FT_PIX_ROUND( FT_MulFix( face->root.ascender, metrics->y_scale ) );
- metrics->descender =
- FT_PIX_ROUND( FT_MulFix( face->root.descender, metrics->y_scale ) );
-- metrics->height =
-- FT_PIX_ROUND( FT_MulFix( face->root.height, metrics->y_scale ) );
- metrics->max_advance =
- FT_PIX_ROUND( FT_MulFix( face->root.max_advance_width,
- metrics->x_scale ) );
-+
-+ /* the height is derived from rounded values */
-+ metrics->height = metrics->ascender - metrics->descender;
- }
-
- /* compute new transformation */
---
-cgit v0.9.0.2