- Revision
- 266160
- Author
- [email protected]
- Date
- 2020-08-25 23:15:20 -0700 (Tue, 25 Aug 2020)
Log Message
Move FreeType port's Font::platformWidthForGlyph and Font::platformBoundsForGlyph for Cairo port (WinCairo port)
https://bugs.webkit.org/show_bug.cgi?id=215838
Reviewed by Carlos Garcia Campos.
WinCairo was using GDI API to implement
Font::platformWidthForGlyph and Font::platformBoundsForGlyph. This
is a problem for Cairo DirectWrite font backend (Bug 215259).
FreeType port has platform independent implementations which are
using Cairo API. Use them for WinCairo.
* platform/graphics/cairo/FontCairo.cpp:
(WebCore::Font::platformBoundsForGlyph const): Moved from SimpleFontDataFreeType.cpp.
(WebCore::Font::platformWidthForGlyph const): Ditto.
* platform/graphics/freetype/SimpleFontDataFreeType.cpp:
(WebCore::Font::platformBoundsForGlyph const): Moved to FontCairo.cpp.
(WebCore::Font::platformWidthForGlyph const): Ditto.
* platform/graphics/win/SimpleFontDataCairoWin.cpp:
(WebCore::Font::platformBoundsForGlyph const): Deleted.
(WebCore::Font::platformWidthForGlyph const): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (266159 => 266160)
--- trunk/Source/WebCore/ChangeLog 2020-08-26 05:17:54 UTC (rev 266159)
+++ trunk/Source/WebCore/ChangeLog 2020-08-26 06:15:20 UTC (rev 266160)
@@ -1,3 +1,26 @@
+2020-08-25 Fujii Hironori <[email protected]>
+
+ Move FreeType port's Font::platformWidthForGlyph and Font::platformBoundsForGlyph for Cairo port (WinCairo port)
+ https://bugs.webkit.org/show_bug.cgi?id=215838
+
+ Reviewed by Carlos Garcia Campos.
+
+ WinCairo was using GDI API to implement
+ Font::platformWidthForGlyph and Font::platformBoundsForGlyph. This
+ is a problem for Cairo DirectWrite font backend (Bug 215259).
+ FreeType port has platform independent implementations which are
+ using Cairo API. Use them for WinCairo.
+
+ * platform/graphics/cairo/FontCairo.cpp:
+ (WebCore::Font::platformBoundsForGlyph const): Moved from SimpleFontDataFreeType.cpp.
+ (WebCore::Font::platformWidthForGlyph const): Ditto.
+ * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
+ (WebCore::Font::platformBoundsForGlyph const): Moved to FontCairo.cpp.
+ (WebCore::Font::platformWidthForGlyph const): Ditto.
+ * platform/graphics/win/SimpleFontDataCairoWin.cpp:
+ (WebCore::Font::platformBoundsForGlyph const): Deleted.
+ (WebCore::Font::platformWidthForGlyph const): Deleted.
+
2020-08-25 Tim Horton <[email protected]>
Web Share API Level 2 functions even when its experimental feature flag is disabled
Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp (266159 => 266160)
--- trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp 2020-08-26 05:17:54 UTC (rev 266159)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp 2020-08-26 06:15:20 UTC (rev 266160)
@@ -96,6 +96,36 @@
return Path(WTFMove(cr));
}
+FloatRect Font::platformBoundsForGlyph(Glyph glyph) const
+{
+ if (!m_platformData.size())
+ return FloatRect();
+
+ cairo_glyph_t cglyph = { glyph, 0, 0 };
+ cairo_text_extents_t extents;
+ cairo_scaled_font_glyph_extents(m_platformData.scaledFont(), &cglyph, 1, &extents);
+
+ if (cairo_scaled_font_status(m_platformData.scaledFont()) == CAIRO_STATUS_SUCCESS)
+ return FloatRect(extents.x_bearing, extents.y_bearing, extents.width, extents.height);
+
+ return FloatRect();
+}
+
+float Font::platformWidthForGlyph(Glyph glyph) const
+{
+ if (!m_platformData.size())
+ return 0;
+
+ if (cairo_scaled_font_status(m_platformData.scaledFont()) != CAIRO_STATUS_SUCCESS)
+ return m_spaceWidth;
+
+ cairo_glyph_t cairoGlyph = { glyph, 0, 0 };
+ cairo_text_extents_t extents;
+ cairo_scaled_font_glyph_extents(m_platformData.scaledFont(), &cairoGlyph, 1, &extents);
+ float width = platformData().orientation() == FontOrientation::Horizontal ? extents.x_advance : -extents.y_advance;
+ return width ? width : m_spaceWidth;
+}
+
} // namespace WebCore
#endif // USE(CAIRO)
Modified: trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp (266159 => 266160)
--- trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2020-08-26 05:17:54 UTC (rev 266159)
+++ trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2020-08-26 06:15:20 UTC (rev 266160)
@@ -206,36 +206,6 @@
m_treatAsFixedPitch = m_platformData.isFixedPitch();
}
-FloatRect Font::platformBoundsForGlyph(Glyph glyph) const
-{
- if (!m_platformData.size())
- return FloatRect();
-
- cairo_glyph_t cglyph = { glyph, 0, 0 };
- cairo_text_extents_t extents;
- cairo_scaled_font_glyph_extents(m_platformData.scaledFont(), &cglyph, 1, &extents);
-
- if (cairo_scaled_font_status(m_platformData.scaledFont()) == CAIRO_STATUS_SUCCESS)
- return FloatRect(extents.x_bearing, extents.y_bearing, extents.width, extents.height);
-
- return FloatRect();
-}
-
-float Font::platformWidthForGlyph(Glyph glyph) const
-{
- if (!m_platformData.size())
- return 0;
-
- if (cairo_scaled_font_status(m_platformData.scaledFont()) != CAIRO_STATUS_SUCCESS)
- return m_spaceWidth;
-
- cairo_glyph_t cairoGlyph = { glyph, 0, 0 };
- cairo_text_extents_t extents;
- cairo_scaled_font_glyph_extents(m_platformData.scaledFont(), &cairoGlyph, 1, &extents);
- float width = platformData().orientation() == FontOrientation::Horizontal ? extents.x_advance : -extents.y_advance;
- return width ? width : m_spaceWidth;
-}
-
bool Font::variantCapsSupportsCharacterForSynthesis(FontVariantCaps fontVariantCaps, UChar32) const
{
switch (fontVariantCaps) {
Modified: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp (266159 => 266160)
--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp 2020-08-26 05:17:54 UTC (rev 266159)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp 2020-08-26 06:15:20 UTC (rev 266160)
@@ -95,49 +95,4 @@
RestoreDC(dc, -1);
}
-FloatRect Font::platformBoundsForGlyph(Glyph glyph) const
-{
- if (m_platformData.useGDI())
- return boundsForGDIGlyph(glyph);
-
- HWndDC dc(0);
- SaveDC(dc);
- auto scaledFont = m_platformData.scaledFont();
- cairo_win32_scaled_font_select_font(scaledFont, dc);
-
- GLYPHMETRICS gdiMetrics;
- static const MAT2 identity = { { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, 1 } };
- GetGlyphOutline(dc, glyph, GGO_METRICS | GGO_GLYPH_INDEX, &gdiMetrics, 0, 0, &identity);
-
- cairo_win32_scaled_font_done_font(scaledFont);
- RestoreDC(dc, -1);
- return FloatRect(gdiMetrics.gmptGlyphOrigin.x, -gdiMetrics.gmptGlyphOrigin.y,
- gdiMetrics.gmBlackBoxX + m_syntheticBoldOffset, gdiMetrics.gmBlackBoxY);
}
-
-float Font::platformWidthForGlyph(Glyph glyph) const
-{
- if (m_platformData.useGDI())
- return widthForGDIGlyph(glyph);
-
- if (!m_platformData.size())
- return 0;
-
- HWndDC dc(0);
- SaveDC(dc);
-
- cairo_scaled_font_t* scaledFont = m_platformData.scaledFont();
- cairo_win32_scaled_font_select_font(scaledFont, dc);
-
- int width;
- GetCharWidthI(dc, glyph, 1, 0, &width);
-
- cairo_win32_scaled_font_done_font(scaledFont);
-
- RestoreDC(dc, -1);
-
- const double metricsMultiplier = cairo_win32_scaled_font_get_metrics_factor(scaledFont) * m_platformData.size();
- return width * metricsMultiplier;
-}
-
-}