Mike Reed | 331ccfd | 2018-10-25 12:36:06 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkTextUtils_DEFINED |
| 9 | #define SkTextUtils_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkCanvas.h" |
| 12 | #include "include/core/SkFont.h" |
| 13 | #include "include/core/SkPaint.h" |
| 14 | #include "include/core/SkString.h" |
Mike Reed | 331ccfd | 2018-10-25 12:36:06 -0400 | [diff] [blame] | 15 | |
Mike Reed | f78b7ea | 2018-12-25 22:06:17 -0500 | [diff] [blame] | 16 | class SkPath; |
| 17 | |
Martin Vejdarski | 8842799 | 2019-04-04 23:32:22 +0700 | [diff] [blame] | 18 | class SK_API SkTextUtils { |
Mike Reed | 331ccfd | 2018-10-25 12:36:06 -0400 | [diff] [blame] | 19 | public: |
Mike Reed | 3a42ec0 | 2018-10-30 12:53:21 -0400 | [diff] [blame] | 20 | enum Align { |
| 21 | kLeft_Align, |
| 22 | kCenter_Align, |
| 23 | kRight_Align, |
| 24 | }; |
| 25 | |
Mike Reed | dc5863c | 2018-12-23 23:19:14 -0500 | [diff] [blame] | 26 | static void Draw(SkCanvas*, const void* text, size_t size, SkTextEncoding, |
| 27 | SkScalar x, SkScalar y, const SkFont&, const SkPaint&, Align = kLeft_Align); |
Mike Reed | 331ccfd | 2018-10-25 12:36:06 -0400 | [diff] [blame] | 28 | |
| 29 | static void DrawString(SkCanvas* canvas, const char text[], SkScalar x, SkScalar y, |
Mike Reed | dc5863c | 2018-12-23 23:19:14 -0500 | [diff] [blame] | 30 | const SkFont& font, const SkPaint& paint, Align align = kLeft_Align) { |
Ben Wagner | 51e15a6 | 2019-05-07 15:38:46 -0400 | [diff] [blame^] | 31 | Draw(canvas, text, strlen(text), SkTextEncoding::kUTF8, x, y, font, paint, align); |
Mike Reed | 331ccfd | 2018-10-25 12:36:06 -0400 | [diff] [blame] | 32 | } |
Mike Reed | dc5863c | 2018-12-23 23:19:14 -0500 | [diff] [blame] | 33 | |
Mike Reed | f78b7ea | 2018-12-25 22:06:17 -0500 | [diff] [blame] | 34 | static void GetPath(const void* text, size_t length, SkTextEncoding, SkScalar x, SkScalar y, |
| 35 | const SkFont&, SkPath*); |
Mike Reed | 331ccfd | 2018-10-25 12:36:06 -0400 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | #endif |