Add text size override to Viewer.

In some cases issues only happen when the actual requested text size on
a paint is a particular size. Allow overriding the text size on the
paint for such testing.

Change-Id: Ic719ea36ba9d624725d443cbd563283628606f2d
Reviewed-on: https://skia-review.googlesource.com/133446
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
Ben Wagner 2018-06-07 17:54:07 -04:00 committed by Skia Commit-Bot
parent 89c5e8878e
commit d2ae4df90d
2 changed files with 20 additions and 0 deletions

View File

@ -1018,6 +1018,9 @@ public:
if (*paint == nullptr) {
return true;
}
if (fPaintOverrides->fTextSize) {
paint->writable()->setTextSize(fPaint->getTextSize());
}
if (fPaintOverrides->fHinting) {
paint->writable()->setHinting(fPaint->getHinting());
}
@ -1651,6 +1654,22 @@ void Viewer::drawImGui() {
"Default\0No Vertical Text\0Vertical Text\0\0",
SkPaint::kVerticalText_Flag,
&SkPaint::isVerticalText, &SkPaint::setVerticalText);
ImGui::Checkbox("Override TextSize", &fPaintOverrides.fTextSize);
if (fPaintOverrides.fTextSize) {
ImGui::DragFloat2("TextRange", fPaintOverrides.fTextSizeRange,
0.001f, -10.0f, 300.0f, "%.6f", 2.0f);
float textSize = fPaint.getTextSize();
if (ImGui::DragFloat("TextSize", &textSize, 0.001f,
fPaintOverrides.fTextSizeRange[0],
fPaintOverrides.fTextSizeRange[1],
"%.6f", 2.0f))
{
fPaint.setTextSize(textSize);
this->preTouchMatrixChanged();
paramsChanged = true;
}
}
}
{

View File

@ -48,6 +48,7 @@ public:
bool fImageFilter = false;
bool fTextSize = false;
SkScalar fTextSizeRange[2] = { 0, 20 };
bool fTextScaleX = false;
bool fTextSkewX = false;
bool fColor = false;