Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Unified Diff: third_party/WebKit/Source/platform/fonts/skia/SkiaTextMetrics.cpp

Issue 2204923002: Untangle HarfBuzz callbacks for glyph width and extents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Untangle HarfBuzz callbacks for glyph width and extents Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/skia/SkiaTextMetrics.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/skia/SkiaTextMetrics.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698