Index: third_party/WebKit/Source/platform/fonts/skia/SkiaTextMetrics.cpp |
diff --git a/third_party/WebKit/Source/platform/fonts/skia/SkiaTextMetrics.cpp b/third_party/WebKit/Source/platform/fonts/skia/SkiaTextMetrics.cpp |
index 05e92c252823f69f8e7659a66ea51207e071b696..4918a7a825d3ee644dc1f612f264e1d42fd2e4e6 100644 |
--- a/third_party/WebKit/Source/platform/fonts/skia/SkiaTextMetrics.cpp |
+++ b/third_party/WebKit/Source/platform/fonts/skia/SkiaTextMetrics.cpp |
@@ -23,34 +23,43 @@ SkiaTextMetrics::SkiaTextMetrics(const SkPaint* paint) |
CHECK(m_paint->getTextEncoding() == SkPaint::kGlyphID_TextEncoding); |
} |
-void SkiaTextMetrics::getGlyphWidthAndExtentsForHarfBuzz(hb_codepoint_t codepoint, hb_position_t* width, hb_glyph_extents_t* extents) |
+ |
+void SkiaTextMetrics::getGlyphWidthForHarfBuzz(hb_codepoint_t codepoint, hb_position_t* width) |
{ |
DCHECK_LE(codepoint, 0xFFFFu); |
+ CHECK(width); |
SkScalar skWidth; |
+ uint16_t glyph = codepoint; |
+ |
+ m_paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, nullptr); |
+ if (!m_paint->isSubpixelText()) |
+ skWidth = SkScalarRoundToInt(skWidth); |
+ *width = SkiaScalarToHarfBuzzPosition(skWidth); |
+} |
+ |
+void SkiaTextMetrics::getGlyphExtentsForHarfBuzz(hb_codepoint_t codepoint, hb_glyph_extents_t* extents) |
+{ |
+ DCHECK_LE(codepoint, 0xFFFFu); |
+ CHECK(extents); |
+ |
SkRect skBounds; |
uint16_t glyph = codepoint; |
- m_paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, &skBounds); |
- if (width) { |
- if (!m_paint->isSubpixelText()) |
- skWidth = SkScalarRoundToInt(skWidth); |
- *width = SkiaScalarToHarfBuzzPosition(skWidth); |
- } |
- if (extents) { |
- if (!m_paint->isSubpixelText()) { |
- // Use roundOut() rather than round() to avoid rendering glyphs |
- // outside the visual overflow rect. crbug.com/452914. |
- SkIRect ir; |
- skBounds.roundOut(&ir); |
- skBounds.set(ir); |
- } |
- // Invert y-axis because Skia is y-grows-down but we set up HarfBuzz to be y-grows-up. |
- extents->x_bearing = SkiaScalarToHarfBuzzPosition(skBounds.fLeft); |
- extents->y_bearing = SkiaScalarToHarfBuzzPosition(-skBounds.fTop); |
- extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); |
- extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); |
+ m_paint->getTextWidths(&glyph, sizeof(glyph), nullptr, &skBounds); |
+ if (!m_paint->isSubpixelText()) { |
+ // Use roundOut() rather than round() to avoid rendering glyphs |
+ // outside the visual overflow rect. crbug.com/452914. |
+ SkIRect ir; |
+ skBounds.roundOut(&ir); |
+ skBounds.set(ir); |
} |
+ |
+ // Invert y-axis because Skia is y-grows-down but we set up HarfBuzz to be y-grows-up. |
+ extents->x_bearing = SkiaScalarToHarfBuzzPosition(skBounds.fLeft); |
+ extents->y_bearing = SkiaScalarToHarfBuzzPosition(-skBounds.fTop); |
+ extents->width = SkiaScalarToHarfBuzzPosition(skBounds.width()); |
+ extents->height = SkiaScalarToHarfBuzzPosition(-skBounds.height()); |
} |
void SkiaTextMetrics::getSkiaBoundsForGlyph(Glyph glyph, SkRect *bounds) |