Flutter Engine
The Flutter Engine
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
Definition: TestTypeface.h:40
const SkUnichar * fCharCodes
Definition: TestTypeface.h:39
const char * fName
Definition: TestTypeface.h:43
const SkFontMetrics & fMetrics
Definition: TestTypeface.h:42
const SkScalar * fPoints
Definition: TestTypeface.h:37
const unsigned char * fVerbs
Definition: TestTypeface.h:38
const SkFixed * fWidths
Definition: TestTypeface.h:41

◆ ~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
Definition: SkPath.h:59
@ kClose_Verb
Definition: SkPath.h:1471
@ kMove_Verb
Definition: SkPath.h:1466
@ kDone_Verb
Definition: SkPath.h:1472
@ kCubic_Verb
Definition: SkPath.h:1470
@ kQuad_Verb
Definition: SkPath.h:1468
@ kLine_Verb
Definition: SkPath.h:1467
static bool b

Friends And Related Function 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: