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
This commit is contained in:
parent
627769144d
commit
fb56218292
@ -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);
|
||||
}
|
||||
|
@ -2525,14 +2525,14 @@ void SkCanvas::DrawTextDecorations(const SkDraw& draw, const SkPaint& paint,
|
||||
start.fY);
|
||||
r.fTop = offset;
|
||||
r.fBottom = offset + height;
|
||||
DrawRect(draw, paint, r, textSize);
|
||||
DrawRect(draw, paint, r, 1);
|
||||
}
|
||||
if (flags & SkPaint::kStrikeThruText_Flag) {
|
||||
SkScalar offset = SkScalarMulAdd(textSize, kStdStrikeThru_Offset,
|
||||
start.fY);
|
||||
r.fTop = offset;
|
||||
r.fBottom = offset + height;
|
||||
DrawRect(draw, paint, r, textSize);
|
||||
DrawRect(draw, paint, r, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user