Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
SkCustomTypefaceBuilder Class Reference

#include <SkCustomTypeface.h>

Public Member Functions

 SkCustomTypefaceBuilder ()
 
void setGlyph (SkGlyphID, float advance, const SkPath &)
 
void setGlyph (SkGlyphID, float advance, sk_sp< SkDrawable >, const SkRect &bounds)
 
void setMetrics (const SkFontMetrics &fm, float scale=1)
 
void setFontStyle (SkFontStyle)
 
sk_sp< SkTypefacedetach ()
 

Static Public Member Functions

static sk_sp< SkTypefaceMakeFromStream (std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
 

Static Public Attributes

static constexpr SkTypeface::FactoryId FactoryId = SkSetFourByteTag('u','s','e','r')
 

Friends

class SkTypeface
 
class SkUserTypeface
 

Detailed Description

Definition at line 27 of file SkCustomTypeface.h.

Constructor & Destructor Documentation

◆ SkCustomTypefaceBuilder()

SkCustomTypefaceBuilder::SkCustomTypefaceBuilder ( )

Definition at line 144 of file SkCustomTypeface.cpp.

144 {
145 sk_bzero(&fMetrics, sizeof(fMetrics));
146}
sk_bzero(glyphs, sizeof(glyphs))

Member Function Documentation

◆ detach()

sk_sp< SkTypeface > SkCustomTypefaceBuilder::detach ( )

Definition at line 180 of file SkCustomTypeface.cpp.

180 {
181 if (fGlyphRecs.empty()) return nullptr;
182
183 // initially inverted, so that any "union" will overwrite the first time
185
186 for (const auto& rec : fGlyphRecs) {
187 bounds.join(rec.isDrawable()
188 ? rec.fBounds
189 : rec.fPath.getBounds());
190 }
191
192 fMetrics.fTop = bounds.top();
193 fMetrics.fBottom = bounds.bottom();
194 fMetrics.fXMin = bounds.left();
195 fMetrics.fXMax = bounds.right();
196
197 return sk_sp<SkUserTypeface>(new SkUserTypeface(fStyle, fMetrics, std::move(fGlyphRecs)));
198}
#define SK_ScalarMax
Definition: SkScalar.h:24
Optional< SkRect > bounds
Definition: SkRecords.h:189
SkScalar fTop
greatest extent above origin of any glyph bounding box, typically negative; deprecated with variable ...
Definition: SkFontMetrics.h:53
SkScalar fBottom
greatest extent below origin of any glyph bounding box, typically positive; deprecated with variable ...
Definition: SkFontMetrics.h:56
SkScalar fXMin
greatest extent to left of origin of any glyph bounding box, typically negative; deprecated with vari...
Definition: SkFontMetrics.h:60
SkScalar fXMax
greatest extent to right of origin of any glyph bounding box, typically positive; deprecated with var...
Definition: SkFontMetrics.h:61

◆ MakeFromStream()

sk_sp< SkTypeface > SkCustomTypefaceBuilder::MakeFromStream ( std::unique_ptr< SkStreamAsset stream,
const SkFontArguments  
)
static

Definition at line 508 of file SkCustomTypeface.cpp.

509 {
510 return Deserialize(stream.get());
511}

◆ setFontStyle()

void SkCustomTypefaceBuilder::setFontStyle ( SkFontStyle  style)

Definition at line 152 of file SkCustomTypeface.cpp.

152 {
153 fStyle = style;
154}

◆ setGlyph() [1/2]

void SkCustomTypefaceBuilder::setGlyph ( SkGlyphID  index,
float  advance,
const SkPath path 
)

Definition at line 164 of file SkCustomTypeface.cpp.

164 {
165 auto& rec = this->ensureStorage(index);
166 rec.fAdvance = advance;
167 rec.fPath = path;
168 rec.fDrawable = nullptr;
169}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57

◆ setGlyph() [2/2]

void SkCustomTypefaceBuilder::setGlyph ( SkGlyphID  index,
float  advance,
sk_sp< SkDrawable drawable,
const SkRect bounds 
)

Definition at line 171 of file SkCustomTypeface.cpp.

172 {
173 auto& rec = this->ensureStorage(index);
174 rec.fAdvance = advance;
175 rec.fDrawable = std::move(drawable);
176 rec.fBounds = bounds;
177 rec.fPath.reset();
178}

◆ setMetrics()

void SkCustomTypefaceBuilder::setMetrics ( const SkFontMetrics fm,
float  scale = 1 
)

Definition at line 148 of file SkCustomTypeface.cpp.

148 {
149 fMetrics = scale_fontmetrics(fm, scale, scale);
150}
static SkFontMetrics scale_fontmetrics(const SkFontMetrics &src, float sx, float sy)
const Scalar scale

Friends And Related Function Documentation

◆ SkTypeface

friend class SkTypeface
friend

Definition at line 65 of file SkCustomTypeface.h.

◆ SkUserTypeface

friend class SkUserTypeface
friend

Definition at line 66 of file SkCustomTypeface.h.

Member Data Documentation

◆ FactoryId

constexpr SkTypeface::FactoryId SkCustomTypefaceBuilder::FactoryId = SkSetFourByteTag('u','s','e','r')
staticconstexpr

Definition at line 39 of file SkCustomTypeface.h.


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