From d2ae4df90d430bb635c7bcc83723a6ee86a81376 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Thu, 7 Jun 2018 17:54:07 -0400 Subject: [PATCH] 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 Commit-Queue: Ben Wagner --- tools/viewer/Viewer.cpp | 19 +++++++++++++++++++ tools/viewer/Viewer.h | 1 + 2 files changed, 20 insertions(+) diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp index 2357a18bb5..65280bc4af 100644 --- a/tools/viewer/Viewer.cpp +++ b/tools/viewer/Viewer.cpp @@ -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; + } + } } { diff --git a/tools/viewer/Viewer.h b/tools/viewer/Viewer.h index d843946ab1..78feabeef2 100644 --- a/tools/viewer/Viewer.h +++ b/tools/viewer/Viewer.h @@ -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;