Index: src/core/SkRecordDraw.cpp |
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp |
index 5981245c018700e8ed969e7abc75e1d76c63b7ba..f85a5eea106ff3292ee3e4cf73ce4d6177be57c6 100644 |
--- a/src/core/SkRecordDraw.cpp |
+++ b/src/core/SkRecordDraw.cpp |
@@ -7,6 +7,7 @@ |
#include "SkRecordDraw.h" |
#include "SkPatchUtils.h" |
+#include "SkTypeface.h" |
void SkRecordDraw(const SkRecord& record, |
SkCanvas* canvas, |
@@ -448,11 +449,9 @@ private: |
SkRect pad = { 0, 0, 0, 0}; |
AdjustTextForFontMetrics(&pad, op.paint); |
- // That maximum padding happens to always be the right pad today. |
- SkASSERT(pad.fLeft == -pad.fRight); |
- SkASSERT(pad.fTop == -pad.fBottom); |
- SkASSERT(pad.fRight > pad.fBottom); |
- dst.outset(pad.fRight, pad.fRight); |
+ SkScalar max = SkTMax(SkTMax(-pad.fLeft, pad.fRight), |
reed1
2014/10/28 17:36:13
/* we take the max, instead of outsetting by each
|
+ SkTMax(-pad.fTop, pad.fBottom)); |
+ dst.outset(max, max); |
return this->adjustAndMap(dst, &op.paint); |
} |
@@ -467,11 +466,18 @@ private: |
#ifdef SK_DEBUG |
SkRect correct = *rect; |
#endif |
- // crbug.com/373785 ~~> xPad = 4x yPad |
- // crbug.com/424824 ~~> bump yPad from 2x text size to 2.5x |
- const SkScalar yPad = 2.5f * paint.getTextSize(), |
- xPad = 4.0f * yPad; |
- rect->outset(xPad, yPad); |
+ SkAutoTUnref<SkTypeface> au; |
+ SkTypeface* tf = paint.getTypeface(); |
+ if (!tf) { |
+ au.reset(SkTypeface::RefDefault()); |
+ tf = au.get(); |
+ } |
+ const SkScalar size = paint.getTextSize(); |
+ const SkRect tb = tf->getBounds(); |
reed1
2014/10/28 17:36:13
// "outset" rect by the corresponding fields in th
|
+ rect->fLeft += size * tb.fLeft; |
+ rect->fRight += size * tb.fRight; |
+ rect->fTop += size * tb.fTop; |
+ rect->fBottom += size * tb.fBottom; |
#ifdef SK_DEBUG |
SkPaint::FontMetrics metrics; |
paint.getFontMetrics(&metrics); |
@@ -481,9 +487,10 @@ private: |
correct.fBottom += metrics.fBottom; |
// See skia:2862 for why we ignore small text sizes. |
SkASSERTF(paint.getTextSize() < 0.001f || rect->contains(correct), |
- "%f %f %f %f vs. %f %f %f %f\n", |
- -xPad, -yPad, +xPad, +yPad, |
- metrics.fXMin, metrics.fTop, metrics.fXMax, metrics.fBottom); |
+ "%f %f %f %f vs. %f %f %f %f, text size %f\n", |
+ size*tb.fLeft, size*tb.fTop, size*tb.fRight, size*tb.fBottom, |
+ metrics.fXMin, metrics.fTop, metrics.fXMax, metrics.fBottom, |
+ paint.getTextSize()); |
#endif |
} |