1
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 */
8#ifndef SkTextLayout_DEFINED
9#define SkTextLayout_DEFINED
10
11#include "SkPaint.h"
12#include "SkRefCnt.h"
13
14class SkTextStyle : public SkRefCnt {
15public:
16    SkTextStyle();
17    SkTextStyle(const SkTextStyle&);
18    explicit SkTextStyle(const SkPaint&);
19    virtual ~SkTextStyle();
20
21    const SkPaint& paint() const { return fPaint; }
22    SkPaint& paint() { return fPaint; }
23
24    // todo: bidi-override, language
25
26private:
27    SkPaint fPaint;
28};
29
30class SkTextLayout {
31public:
32    SkTextLayout();
33    ~SkTextLayout();
34
35    void setText(const char text[], size_t length);
36    void setBounds(const SkRect& bounds);
37
38    SkTextStyle* getDefaultStyle() const { return fDefaultStyle; }
39    SkTextStyle* setDefaultStyle(SkTextStyle*);
40
41//    SkTextStyle* setStyle(SkTextStyle*, size_t offset, size_t length);
42
43    void draw(SkCanvas* canvas);
44
45private:
46    SkTDArray<char> fText;
47    SkTextStyle*    fDefaultStyle;
48    SkRect          fBounds;
49
50    // cache
51    struct Line;
52    struct GlyphRun;
53    SkTDArray<Line*> fLines;
54};
55
56#endif
57
58