1 /* 2 * Copyright 2012 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 SkTextToPathIter_DEFINED 9 #define SkTextToPathIter_DEFINED 10 11 #include "SkAutoKern.h" 12 #include "SkPaint.h" 13 14 class SkGlyphCache; 15 16 class SkTextToPathIter { 17 public: 18 SkTextToPathIter(const char text[], size_t length, const SkPaint& paint, 19 bool applyStrokeAndPathEffects); 20 ~SkTextToPathIter(); 21 22 const SkPaint& getPaint() const { return fPaint; } 23 SkScalar getPathScale() const { return fScale; } 24 25 struct Rec { 26 const SkPath* fPath; // may be null for "whitespace" glyphs 27 SkScalar fXPos; 28 }; 29 30 /** 31 * Returns false when all of the text has been consumed 32 */ 33 bool next(const SkPath** path, SkScalar* xpos); 34 35 private: 36 SkGlyphCache* fCache; 37 SkPaint fPaint; 38 SkScalar fScale; 39 SkFixed fPrevAdvance; 40 const char* fText; 41 const char* fStop; 42 SkMeasureCacheProc fGlyphCacheProc; 43 44 const SkPath* fPath; // returned in next 45 SkScalar fXPos; // accumulated xpos, returned in next 46 SkAutoKern fAutoKern; 47 int fXYIndex; // cache for horizontal -vs- vertical text 48 }; 49 50 #endif 51