From 4e2033e84374e3487fa05dd64fd4da143d4498ea Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Tue, 25 Jun 2019 16:25:20 -0400 Subject: [PATCH] Use rect calls in SkFont Change-Id: Ib51519180136f8907f418808c96a01d403dcf7a5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223799 Reviewed-by: Ben Wagner Commit-Queue: Herb Derby --- src/core/SkFont.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/core/SkFont.cpp b/src/core/SkFont.cpp index 9d003da6e2..0f424de211 100644 --- a/src/core/SkFont.cpp +++ b/src/core/SkFont.cpp @@ -210,17 +210,13 @@ int SkFont::textToGlyphs(const void* text, size_t byteLength, SkTextEncoding enc } static void set_bounds(const SkGlyph& g, SkRect* bounds) { - bounds->set(SkIntToScalar(g.fLeft), - SkIntToScalar(g.fTop), - SkIntToScalar(g.fLeft + g.fWidth), - SkIntToScalar(g.fTop + g.fHeight)); + *bounds = g.rect(); } static void join_bounds_x(const SkGlyph& g, SkRect* bounds, SkScalar dx) { - bounds->join(SkIntToScalar(g.fLeft) + dx, - SkIntToScalar(g.fTop), - SkIntToScalar(g.fLeft + g.fWidth) + dx, - SkIntToScalar(g.fTop + g.fHeight)); + SkRect r = g.rect(); + r.offset(dx, 0); + bounds->join(r); } namespace { @@ -278,12 +274,7 @@ SkScalar SkFont::measureText(const void* text, size_t length, SkTextEncoding enc } static SkRect make_bounds(const SkGlyph& g, SkScalar scale) { - return { - g.fLeft * scale, - g.fTop * scale, - (g.fLeft + g.fWidth) * scale, - (g.fTop + g.fHeight) * scale - }; + return SkMatrix::MakeScale(scale).mapRect(g.rect()); } template