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

Unified Diff: src/core/SkPaint.cpp

Issue 804903006: add paint::getFontBounds() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « include/core/SkPaint.h ('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 162988beeb145a50e6a3616383a46a6b67d8cfdf..ff08a0a65f571695d0ccc11e53b79d5563a15408 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));
« no previous file with comments | « include/core/SkPaint.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698