blob: 30a66a7ceb1a2af589027c512ec22428525c1077 [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
11#include "SkCanvas.h"
12#include "SkPaint.h"
13#include "SkFont.h"
14#include "SkString.h"
15
16class SkTextUtils {
17public:
Mike Reed3a42ec02018-10-30 12:53:21 -040018 enum Align {
19 kLeft_Align,
20 kCenter_Align,
21 kRight_Align,
22 };
23
Mike Reed331ccfd2018-10-25 12:36:06 -040024 static void DrawText(SkCanvas*, const void* text, size_t size, SkScalar x, SkScalar y,
Mike Reed3a42ec02018-10-30 12:53:21 -040025 const SkPaint&, Align = kLeft_Align);
Mike Reed331ccfd2018-10-25 12:36:06 -040026
27 static void DrawString(SkCanvas* canvas, const char text[], SkScalar x, SkScalar y,
Mike Reed3a42ec02018-10-30 12:53:21 -040028 const SkPaint& paint, Align align = kLeft_Align) {
Mike Reed331ccfd2018-10-25 12:36:06 -040029 DrawText(canvas, text, strlen(text), x, y, paint, align);
30 }
31 static void DrawString(SkCanvas* canvas, const SkString& str, SkScalar x, SkScalar y,
Mike Reed3a42ec02018-10-30 12:53:21 -040032 const SkPaint& paint, Align align = kLeft_Align) {
Mike Reed331ccfd2018-10-25 12:36:06 -040033 DrawText(canvas, str.c_str(), str.size(), x, y, paint, align);
34 }
35};
36
37#endif