Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
SkTestFont Class Reference

#include <TestTypeface.h>

Inheritance diagram for SkTestFont:
SkRefCnt SkRefCntBase

Public Member Functions

 SkTestFont (const SkTestFontData &)
 
 ~SkTestFont () override
 
SkGlyphID glyphForUnichar (SkUnichar charCode) const
 
void init (const SkScalar *pts, const unsigned char *verbs)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Friends

class TestTypeface
 

Detailed Description

Definition at line 47 of file TestTypeface.h.

Constructor & Destructor Documentation

◆ SkTestFont()

SkTestFont::SkTestFont ( const SkTestFontData fontData)

Definition at line 70 of file TestTypeface.cpp.

71 : INHERITED()
72 , fCharCodes(fontData.fCharCodes)
73 , fCharCodesCount(fontData.fCharCodes ? fontData.fCharCodesCount : 0)
74 , fWidths(fontData.fWidths)
75 , fMetrics(fontData.fMetrics)
76 , fName(fontData.fName)
77 , fPaths(nullptr) {
78 init(fontData.fPoints, fontData.fVerbs);
79}
void init(const SkScalar *pts, const unsigned char *verbs)
const size_t fCharCodesCount
const SkUnichar * fCharCodes
const SkScalar * fPoints
const unsigned char * fVerbs

◆ ~SkTestFont()

SkTestFont::~SkTestFont ( )
override

Definition at line 81 of file TestTypeface.cpp.

81 {
82 delete[] fPaths;
83}

Member Function Documentation

◆ glyphForUnichar()

SkGlyphID SkTestFont::glyphForUnichar ( SkUnichar  charCode) const

Definition at line 85 of file TestTypeface.cpp.

85 {
86 for (size_t index = 0; index < fCharCodesCount; ++index) {
87 if (fCharCodes[index] == charCode) {
88 return SkTo<SkGlyphID>(index);
89 }
90 }
91 return 0;
92}

◆ init()

void SkTestFont::init ( const SkScalar pts,
const unsigned char *  verbs 
)

Definition at line 94 of file TestTypeface.cpp.

94 {
95 fPaths = new SkPath[fCharCodesCount];
96 for (unsigned index = 0; index < fCharCodesCount; ++index) {
98 SkPath::Verb verb;
99 while ((verb = (SkPath::Verb)*verbs++) != SkPath::kDone_Verb) {
100 switch (verb) {
102 b.moveTo(pts[0], pts[1]);
103 pts += 2;
104 break;
106 b.lineTo(pts[0], pts[1]);
107 pts += 2;
108 break;
110 b.quadTo(pts[0], pts[1], pts[2], pts[3]);
111 pts += 4;
112 break;
114 b.cubicTo(pts[0], pts[1], pts[2], pts[3], pts[4], pts[5]);
115 pts += 6;
116 break;
118 b.close();
119 break;
120 default:
121 SK_ABORT("bad verb");
122 }
123 }
124 fPaths[index] = b.detach();
125 }
126}
#define SK_ABORT(message,...)
Definition SkAssert.h:70
SkPathBuilder & close()
SkPathBuilder & lineTo(SkPoint pt)
SkPathBuilder & cubicTo(SkPoint pt1, SkPoint pt2, SkPoint pt3)
SkPathBuilder & moveTo(SkPoint pt)
SkPathBuilder & quadTo(SkPoint pt1, SkPoint pt2)
SkPath detach()
Definition SkPath.h:147
@ kClose_Verb
Definition SkPath.h:1463
@ kMove_Verb
Definition SkPath.h:1458
@ kDone_Verb
Definition SkPath.h:1464
@ kCubic_Verb
Definition SkPath.h:1462
@ kQuad_Verb
Definition SkPath.h:1460
@ kLine_Verb
Definition SkPath.h:1459
static bool b

Friends And Related Symbol Documentation

◆ TestTypeface

friend class TestTypeface
friend

Definition at line 61 of file TestTypeface.h.


The documentation for this class was generated from the following files: