blob: 718acdbc5a2899db003e68329ce84bba163e5335 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
reed@android.comed8dbf72010-02-11 13:56:04 +00008#ifndef SkTextLayout_DEFINED
9#define SkTextLayout_DEFINED
10
11#include "SkPaint.h"
12#include "SkRefCnt.h"
13
14class SkTextStyle : public SkRefCnt {
15public:
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +000016 SK_DECLARE_INST_COUNT(SkTextStyle)
17
reed@android.comed8dbf72010-02-11 13:56:04 +000018 SkTextStyle();
19 SkTextStyle(const SkTextStyle&);
20 explicit SkTextStyle(const SkPaint&);
21 virtual ~SkTextStyle();
22
23 const SkPaint& paint() const { return fPaint; }
24 SkPaint& paint() { return fPaint; }
rmistry@google.comfbfcd562012-08-23 18:09:54 +000025
reed@android.comed8dbf72010-02-11 13:56:04 +000026 // todo: bidi-override, language
27
28private:
29 SkPaint fPaint;
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +000030
31 typedef SkRefCnt INHERITED;
reed@android.comed8dbf72010-02-11 13:56:04 +000032};
33
34class SkTextLayout {
35public:
36 SkTextLayout();
37 ~SkTextLayout();
38
39 void setText(const char text[], size_t length);
40 void setBounds(const SkRect& bounds);
41
42 SkTextStyle* getDefaultStyle() const { return fDefaultStyle; }
43 SkTextStyle* setDefaultStyle(SkTextStyle*);
44
45// SkTextStyle* setStyle(SkTextStyle*, size_t offset, size_t length);
46
47 void draw(SkCanvas* canvas);
48
49private:
50 SkTDArray<char> fText;
51 SkTextStyle* fDefaultStyle;
52 SkRect fBounds;
53
54 // cache
55 struct Line;
56 struct GlyphRun;
57 SkTDArray<Line*> fLines;
58};
59
60#endif