50 lines
2.5 KiB
Diff
50 lines
2.5 KiB
Diff
From 496b2994ce4193222fc140eebde4a610e945790e Mon Sep 17 00:00:00 2001
|
|
From: Michael Catanzaro <mcatanzaro@redhat.com>
|
|
Date: Mon, 17 Apr 2023 11:03:43 -0500
|
|
Subject: [PATCH] REGRESSION(262860@main): [GTK] icons broken, rendering errors
|
|
on reddit.com and many other websites, flickering on cnn.com
|
|
https://bugs.webkit.org/show_bug.cgi?id=255488
|
|
|
|
Reviewed by NOBODY (OOPS!).
|
|
|
|
The second parameter to cairo_scaled_font_text_extents() must be a
|
|
NUL-terminated UTF-8 string.
|
|
|
|
* Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp:
|
|
(WebCore::heightOfCharacter):
|
|
(WebCore::Font::platformInit):
|
|
---
|
|
.../graphics/freetype/SimpleFontDataFreeType.cpp | 9 +++++----
|
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
|
|
index fa58a247fa32..7cf29fc9ca89 100644
|
|
--- a/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
|
|
+++ b/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
|
|
@@ -96,10 +96,11 @@ static std::optional<unsigned> fontUnitsPerEm(FT_Face freeTypeFace)
|
|
return std::nullopt;
|
|
}
|
|
|
|
-static float heightOfCharacter(cairo_scaled_font_t* scaledFont, const char character, FontOrientation orientation)
|
|
+static float heightOfCharacter(cairo_scaled_font_t* scaledFont, const char* character, FontOrientation orientation)
|
|
{
|
|
+ ASSERT(strlen(character) == 1);
|
|
cairo_text_extents_t textExtents;
|
|
- cairo_scaled_font_text_extents(scaledFont, &character, &textExtents);
|
|
+ cairo_scaled_font_text_extents(scaledFont, character, &textExtents);
|
|
return narrowPrecisionToFloat(orientation == FontOrientation::Horizontal ? textExtents.height : textExtents.width);
|
|
}
|
|
|
|
@@ -158,9 +159,9 @@ void Font::platformInit()
|
|
// We approximate capHeight and xHeight from cairo_text_extents_t unless
|
|
// FreeType returns them above. This approach is less precise than using FreeType.
|
|
if (!capHeight.has_value() || !capHeight.value())
|
|
- capHeight = heightOfCharacter(m_platformData.scaledFont(), 'T', platformData().orientation());
|
|
+ capHeight = heightOfCharacter(m_platformData.scaledFont(), "T", platformData().orientation());
|
|
if (!xHeight.has_value() || !xHeight.value())
|
|
- xHeight = heightOfCharacter(m_platformData.scaledFont(), 'x', platformData().orientation());
|
|
+ xHeight = heightOfCharacter(m_platformData.scaledFont(), "x", platformData().orientation());
|
|
|
|
m_fontMetrics.setAscent(ascent);
|
|
m_fontMetrics.setDescent(descent);
|