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 11 #include "include/core/SkFontTypes.h" 12 #include "include/core/SkScalar.h" 13 #include "include/core/SkTypes.h" 14 15 #include <cstddef> 16 #include <string> 17 18 class SkCanvas; 19 class SkFont; 20 class SkPaint; 21 class SkPath; 22 23 class SK_API SkTextUtils { 24 public: 25 enum Align { 26 kLeft_Align, 27 kCenter_Align, 28 kRight_Align, 29 }; 30 31 static void Draw(SkCanvas*, const void* text, size_t size, SkTextEncoding, 32 SkScalar x, SkScalar y, const SkFont&, const SkPaint&, Align = kLeft_Align); 33 34 static void DrawString(SkCanvas* canvas, const char text[], SkScalar x, SkScalar y, 35 const SkFont& font, const SkPaint& paint, Align align = kLeft_Align) { 36 Draw(canvas, text, strlen(text), SkTextEncoding::kUTF8, x, y, font, paint, align); 37 } 38 39 static void GetPath(const void* text, size_t length, SkTextEncoding, SkScalar x, SkScalar y, 40 const SkFont&, SkPath*); 41 }; 42 43 #endif 44