aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/texteffects.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2015-12-21 08:35:51 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-21 08:35:51 -0800
commitfb56218292d6c7b509d382f39994c3783b2483a0 (patch)
tree9f1f45649cc89c440f9fbaa99ca7071d26524e80 /gm/texteffects.cpp
parent627769144d233b3abce5ee86cf315df61fa8dcd7 (diff)
fix stroked text underline / strikethrough
Pass 1 to DrawRect for underline and strikethrough since it will scale by the text size later. R=reed@google.com BUG=skia:971 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1535793004 Review URL: https://codereview.chromium.org/1535793004
Diffstat (limited to 'gm/texteffects.cpp')
-rw-r--r--gm/texteffects.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp
index 53395f0732..2eb76efa19 100644
--- a/gm/texteffects.cpp
+++ b/gm/texteffects.cpp
@@ -196,3 +196,35 @@ DEF_SIMPLE_GM(texteffects, canvas, 460, 680) {
canvas->restore();
}
+
+DEF_SIMPLE_GM(textunderstrike, canvas, 460, 680) {
+ canvas->clear(SK_ColorYELLOW);
+ SkPaint paint;
+ sk_tool_utils::set_portable_typeface(&paint);
+ paint.setTextSize(50);
+ paint.setStrokeWidth(5);
+ paint.setAntiAlias(true);
+
+ auto drawText = [&]() {
+ paint.setStyle(SkPaint::kFill_Style);
+ canvas->drawText("Hello", 5, 100, 50, paint);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawText("Hello", 5, 100, 100, paint);
+ canvas->translate(0, 100);
+ };
+
+ drawText();
+ paint.setUnderlineText(true);
+ drawText();
+ paint.setUnderlineText(false);
+ paint.setStrikeThruText(true);
+ drawText();
+ paint.setUnderlineText(true);
+ drawText();
+ paint.setColor(SK_ColorWHITE);
+ paint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawText("Hello", 5, 100, 50, paint);
+ paint.setColor(SK_ColorBLUE);
+ paint.setStyle(SkPaint::kFill_Style);
+ canvas->drawText("Hello", 5, 100, 50, paint);
+}