aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkCanvas.h
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@google.com>2017-04-28 15:35:12 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-28 20:41:04 +0000
commit2a475eae622adc1e8fa29206be1eaf862c23548e (patch)
tree6bad5dbe2ef7aad1c7e657df6bd8cfe3a752c5fd /include/core/SkCanvas.h
parentec138b40ba940ab0d76b5550ee2c5505629c5293 (diff)
add drawString helper to canvas
Many tests and examples use drawText with a guess of how long the text is in bytes, or a call to strlen(). Add a helper to SkCanvas to simplify these examples. Add another helper for SkString. R=reed@google.com Change-Id: I0204a31e938f065606f08ee7cd9a6b36db791ee2 Reviewed-on: https://skia-review.googlesource.com/13642 Commit-Queue: Cary Clark <caryclark@google.com> Reviewed-by: Cary Clark <caryclark@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'include/core/SkCanvas.h')
-rw-r--r--include/core/SkCanvas.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 33a51f7755..7b6ef7de68 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -950,6 +950,29 @@ public:
void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint);
+ /** Draw null-terminated UTF-8 string, with origin at (x,y), using the specified paint.
+ The origin is interpreted based on the Align setting in the paint.
+ @param string The null-terminated string to be drawn
+ @param x The x-coordinate of the origin of the string being drawn
+ @param y The y-coordinate of the origin of the string being drawn
+ @param paint The paint used for the string (e.g. color, size, style)
+ */
+ void drawString(const char* string, SkScalar x, SkScalar y, const SkPaint& paint) {
+ if (!string) {
+ return;
+ }
+ this->drawText(string, strlen(string), x, y, paint);
+ }
+
+ /** Draw string, with origin at (x,y), using the specified paint.
+ The origin is interpreted based on the Align setting in the paint.
+ @param string The string to be drawn
+ @param x The x-coordinate of the origin of the string being drawn
+ @param y The y-coordinate of the origin of the string being drawn
+ @param paint The paint used for the string (e.g. color, size, style)
+ */
+ void drawString(const SkString& string, SkScalar x, SkScalar y, const SkPaint& paint);
+
/** Draw the text, with each character/glyph origin specified by the pos[]
array. The origin is interpreted by the Align setting in the paint.
@param text The text to be drawn