diff options
author | 2014-12-15 13:27:26 -0800 | |
---|---|---|
committer | 2014-12-15 13:27:26 -0800 | |
commit | 8893e5f030cb2f6c3bdf698c1767a244ae098a5c (patch) | |
tree | fffcf4764dec0e269a0abb9cb92aec5186aacea3 /src/core/SkPaint.cpp | |
parent | caaf8e611d4cf373218bae21371cf8cdb3c2c574 (diff) |
add paint::getFontBounds()
BUG=skia:
Review URL: https://codereview.chromium.org/804903006
Diffstat (limited to 'src/core/SkPaint.cpp')
-rw-r--r-- | src/core/SkPaint.cpp | 15 |
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)); |