1 diff --git a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
2 --- a/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
3 +++ b/gfx/cairo/cairo/src/cairo-dwrite-font.cpp
4 @@ -582,22 +582,37 @@ _cairo_dwrite_scaled_font_init_glyph_met
5 DWRITE_FONT_METRICS fontMetrics;
6 font_face->dwriteface->GetMetrics(&fontMetrics);
7 HRESULT hr = font_face->dwriteface->GetDesignGlyphMetrics(&charIndex, 1, &metrics);
9 return CAIRO_INT_STATUS_UNSUPPORTED;
12 // TODO: Treat swap_xy.
13 - extents.width = (FLOAT)(metrics.advanceWidth - metrics.leftSideBearing - metrics.rightSideBearing) / fontMetrics.designUnitsPerEm;
14 - extents.height = (FLOAT)(metrics.advanceHeight - metrics.topSideBearing - metrics.bottomSideBearing) / fontMetrics.designUnitsPerEm;
15 + extents.width = (FLOAT)(metrics.advanceWidth - metrics.leftSideBearing - metrics.rightSideBearing) /
16 + fontMetrics.designUnitsPerEm;
17 + extents.height = (FLOAT)(metrics.advanceHeight - metrics.topSideBearing - metrics.bottomSideBearing) /
18 + fontMetrics.designUnitsPerEm;
19 extents.x_advance = (FLOAT)metrics.advanceWidth / fontMetrics.designUnitsPerEm;
20 extents.x_bearing = (FLOAT)metrics.leftSideBearing / fontMetrics.designUnitsPerEm;
21 extents.y_advance = 0.0;
22 - extents.y_bearing = (FLOAT)(metrics.topSideBearing - metrics.verticalOriginY) / fontMetrics.designUnitsPerEm;
23 + extents.y_bearing = (FLOAT)(metrics.topSideBearing - metrics.verticalOriginY) /
24 + fontMetrics.designUnitsPerEm;
26 + // We pad the extents here because GetDesignGlyphMetrics returns "ideal" metrics
27 + // for the glyph outline, without accounting for hinting/gridfitting/antialiasing,
28 + // and therefore it does not always cover all pixels that will actually be touched.
29 + if (scaled_font->base.options.antialias != CAIRO_ANTIALIAS_NONE &&
30 + extents.width > 0 && extents.height > 0) {
31 + extents.width += scaled_font->mat_inverse.xx * 2;
32 + extents.x_bearing -= scaled_font->mat_inverse.xx;
33 + extents.height += scaled_font->mat_inverse.yy * 2;
34 + extents.y_bearing -= scaled_font->mat_inverse.yy;
37 _cairo_scaled_glyph_set_metrics (scaled_glyph,
40 return CAIRO_INT_STATUS_SUCCESS;
44 * Stack-based helper implementing IDWriteGeometrySink.