Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: src/core/SkPaint.cpp

Issue 284763010: fix the rendering error for drawPosText_asPaths (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: also fix the rendering error for text with path effects Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkDraw.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPaint.cpp
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 88e5b432eb8d714bb4ae52d716844d22f01e537a..bd3961a5ae6039c282997031769a44d76e3c82c7 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -996,8 +996,25 @@ SkScalar SkPaint::setupForAsPaths() {
this->setHinting(SkPaint::kNo_Hinting);
SkScalar textSize = fTextSize;
- this->setTextSize(kCanonicalTextSizeForPaths);
- return textSize / kCanonicalTextSizeForPaths;
+ SkScalar scale = SK_Scalar1;
+
+ // path effect will affects the generation of path for text, don't change
+ // SkPaint if it exists. If no path effect, text drawing is based on
+ // canonical text, so textSize and strokeWidth need to be reset. However,
+ // hairline stroked text is treated as filled to generate its path.
+ if (NULL == this->getPathEffect()) {
+ this->setTextSize(kCanonicalTextSizeForPaths);
+ scale = textSize / kCanonicalTextSizeForPaths;
+
+ if (this->getStrokeWidth() > 0 &&
+ SkPaint::kFill_Style != this->getStyle()) {
+ this->setStrokeWidth(SkScalarDiv(this->getStrokeWidth(), scale));
+ } else {
+ this->setStyle(SkPaint::kFill_Style);
+ }
+ }
+
+ return scale;
}
class SkCanonicalizePaint {
« no previous file with comments | « src/core/SkDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698