aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPaint.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-12-15 13:27:26 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-12-15 13:27:26 -0800
commit8893e5f030cb2f6c3bdf698c1767a244ae098a5c (patch)
treefffcf4764dec0e269a0abb9cb92aec5186aacea3 /src/core/SkPaint.cpp
parentcaaf8e611d4cf373218bae21371cf8cdb3c2c574 (diff)
add paint::getFontBounds()
Diffstat (limited to 'src/core/SkPaint.cpp')
-rw-r--r--src/core/SkPaint.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 162988beeb..ff08a0a65f 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -1237,6 +1237,21 @@ void SkPaint::getPosTextPath(const void* textData, size_t length,
}
}
+SkRect SkPaint::getFontBounds() const {
+ SkMatrix m;
+ m.setScale(fTextSize * fTextScaleX, fTextSize);
+ m.postSkew(fTextSkewX, 0);
+
+ SkTypeface* typeface = this->getTypeface();
+ if (NULL == typeface) {
+ typeface = SkTypeface::GetDefaultTypeface();
+ }
+
+ SkRect bounds;
+ m.mapRect(&bounds, typeface->getBounds());
+ return bounds;
+}
+
static void add_flattenable(SkDescriptor* desc, uint32_t tag,
SkWriteBuffer* buffer) {
buffer->writeToMemory(desc->addEntry(tag, buffer->bytesWritten(), NULL));