diff options
author | Peter Eliasson <peter.eliasson.x@sonyericsson.com> | 2010-05-11 10:44:23 +0200 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2010-05-11 11:37:05 -0700 |
commit | 23cd3d45d67b9dc1071eb771411a00a204048ae7 (patch) | |
tree | 4d7377cbcfbec2b3ff734094cb26fa6b8cfa968d | |
parent | 97615b8c5e62abbb520ab3d538f78b420994f6b4 (diff) | |
download | skia-23cd3d45d67b9dc1071eb771411a00a204048ae7.tar.gz |
Corrected a bug in SkPaint::breakText.
The bug occurs when linear text is meassured. E.g. without this
correction, the following test case will fail
String s = new String("abcdef");
Paint p = new Paint();
p.setLinearText(true);
float width = p.measureText(s);
int numberOfCharacters = p.breakText(s, true, width, null);
assertTrue(numberOfCharacters == s.length());
The reason for this bug is that canonical text size is used to messure
linear text while the maxWidth is not scaled correspondingly.
Change-Id: Iede2d769e43e0914f3e877ee1f46eeeb6b5405ac
Signed-off-by: Peter Eliasson <peter.eliasson.x@sonyericsson.com>
-rw-r--r-- | src/core/SkPaint.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 2432ee3059..f3377ebaa9 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -816,6 +816,7 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth, if (this->isLinearText()) { scale = fTextSize / kCanonicalTextSizeForPaths; + maxWidth = SkScalarMul(maxWidth, SkScalarDiv(kCanonicalTextSizeForPaths, fTextSize)); // this gets restored by restore ((SkPaint*)this)->setTextSize(SkIntToScalar(kCanonicalTextSizeForPaths)); } |