[WinCairo] Implement Font::platformBoundsForGlyph
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Aug 2017 01:08:48 +0000 (01:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Aug 2017 01:08:48 +0000 (01:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174813

Patch by Fujii Hironori <Hironori.Fujii@sony.com> on 2017-08-01
Reviewed by Alex Christensen.

Test: fast/text/emphasis.html

* platform/graphics/win/SimpleFontDataCairoWin.cpp:
(WebCore::Font::platformBoundsForGlyph): Implemented by copying
the code from Font::boundsForGDIGlyph().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220117 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/win/SimpleFontDataCairoWin.cpp

index 40b8b4bafc0135480fecce2f402c7a06e892b8e1..c947366fa3ee51922555240766af824fdaa95230 100644 (file)
@@ -1,3 +1,16 @@
+2017-08-01  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [WinCairo] Implement Font::platformBoundsForGlyph
+        https://bugs.webkit.org/show_bug.cgi?id=174813
+
+        Reviewed by Alex Christensen.
+
+        Test: fast/text/emphasis.html
+
+        * platform/graphics/win/SimpleFontDataCairoWin.cpp:
+        (WebCore::Font::platformBoundsForGlyph): Implemented by copying
+        the code from Font::boundsForGDIGlyph().
+
 2017-08-01  Zalan Bujtas  <zalan@apple.com>
 
         REGRESSION (r217197): New Yorker website hangs for a long time on load, lots of blank tiles
index f795a5f177c234e63d799e1bcc6345fd283b1d27..2c711b8c954665eb26ca78e4ada883ae110177c3 100644 (file)
@@ -109,8 +109,20 @@ FloatRect Font::platformBoundsForGlyph(Glyph glyph) const
 {
     if (m_platformData.useGDI())
         return boundsForGDIGlyph(glyph);
-    //FIXME: Implement this
-    return FloatRect();
+
+    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