Home | History | Annotate | Download | only in text
      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 
     14 class SkTextStyle : public SkRefCnt {
     15 public:
     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 
     26 private:
     27     SkPaint fPaint;
     28 };
     29 
     30 class SkTextLayout {
     31 public:
     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 
     45 private:
     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