blob: 9bff22abfca291966c9175b4dd0b70d1112cad0f [file] [log] [blame]
Mike Reed331ccfd2018-10-25 12:36:06 -04001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkCanvas.h"
12#include "include/core/SkFont.h"
13#include "include/core/SkPaint.h"
14#include "include/core/SkString.h"
Mike Reed331ccfd2018-10-25 12:36:06 -040015
Mike Reedf78b7ea2018-12-25 22:06:17 -050016class SkPath;
17
Martin Vejdarski88427992019-04-04 23:32:22 +070018class SK_API SkTextUtils {
Mike Reed331ccfd2018-10-25 12:36:06 -040019public:
Mike Reed3a42ec02018-10-30 12:53:21 -040020 enum Align {
21 kLeft_Align,
22 kCenter_Align,
23 kRight_Align,
24 };
25
Mike Reeddc5863c2018-12-23 23:19:14 -050026 static void Draw(SkCanvas*, const void* text, size_t size, SkTextEncoding,
27 SkScalar x, SkScalar y, const SkFont&, const SkPaint&, Align = kLeft_Align);
Mike Reed331ccfd2018-10-25 12:36:06 -040028
29 static void DrawString(SkCanvas* canvas, const char text[], SkScalar x, SkScalar y,
Mike Reeddc5863c2018-12-23 23:19:14 -050030 const SkFont& font, const SkPaint& paint, Align align = kLeft_Align) {
Mike Reeddc5863c2018-12-23 23:19:14 -050031 Draw(canvas, text, strlen(text), kUTF8_SkTextEncoding, x, y, font, paint, align);
Mike Reed331ccfd2018-10-25 12:36:06 -040032 }
Mike Reeddc5863c2018-12-23 23:19:14 -050033
Mike Reedf78b7ea2018-12-25 22:06:17 -050034 static void GetPath(const void* text, size_t length, SkTextEncoding, SkScalar x, SkScalar y,
35 const SkFont&, SkPath*);
Mike Reed331ccfd2018-10-25 12:36:06 -040036};
37
38#endif