From 17bca9a4ea63607b5cccb91ff4bce6870aefd079 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Fri, 22 Jun 2018 15:27:52 -0400 Subject: Make fontmgr_bounds change with veryVerbose When using the --veryVerbose command line flag, make the fontmgr_bounds gm label each box with the name of the typeface and the glyph ids used for each extrema. Change-Id: Icf029366e51688cb4be1a3369f6d24bcba8386aa Reviewed-on: https://skia-review.googlesource.com/137190 Reviewed-by: Ben Wagner Commit-Queue: Ben Wagner --- gm/fontmgr.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'gm') diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp index 58c569c300..c3fff702dd 100644 --- a/gm/fontmgr.cpp +++ b/gm/fontmgr.cpp @@ -8,6 +8,7 @@ #include "gm.h" #include "sk_tool_utils.h" #include "SkCanvas.h" +#include "SkCommonFlags.h" #include "SkFontMgr.h" #include "SkPath.h" #include "SkGraphics.h" @@ -265,13 +266,38 @@ public: } } SkGlyphID str[] = { left, right, top, bottom }; + SkPoint location[] = { + {fontBounds.left(), fontBounds.centerY()}, + {fontBounds.right(), fontBounds.centerY()}, + {fontBounds.centerX(), fontBounds.top()}, + {fontBounds.centerX(), fontBounds.bottom()} + }; + + SkPaint labelPaint; + labelPaint.setAntiAlias(true); + sk_tool_utils::set_portable_typeface(&labelPaint); + if (FLAGS_veryVerbose) { + SkString name; + paint.getTypeface()->getFamilyName(&name); + canvas->drawText(name.c_str(), name.size(), + fontBounds.fLeft, fontBounds.fBottom, labelPaint); + } for (size_t i = 0; i < SK_ARRAY_COUNT(str); ++i) { SkPath path; glyphPaint.getTextPath(&str[i], sizeof(str[0]), x, y, &path); SkPaint::Style style = path.isEmpty() ? SkPaint::kFill_Style : SkPaint::kStroke_Style; glyphPaint.setStyle(style); canvas->drawText(&str[i], sizeof(str[0]), x, y, glyphPaint); + + if (FLAGS_veryVerbose) { + SkString glyphStr; + glyphStr.appendS32(str[i]); + canvas->drawText(glyphStr.c_str(), glyphStr.size(), + location[i].fX, location[i].fY, labelPaint); + } + } + } protected: -- cgit v1.2.3