aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar Ben Wagner <bungeman@google.com>2018-06-22 15:27:52 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-22 20:18:27 +0000
commit17bca9a4ea63607b5cccb91ff4bce6870aefd079 (patch)
treea26619abd62518ce6b9a7247031c690696547a62 /gm
parenta199b2bb020b8adebe231ce56aab88c8e8f19678 (diff)
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 <benjaminwagner@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'gm')
-rw-r--r--gm/fontmgr.cpp26
1 files changed, 26 insertions, 0 deletions
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: