Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
TestTypeface Class Reference

#include <TestTypeface.h>

Inheritance diagram for TestTypeface:
SkTypeface SkWeakRefCnt SkRefCnt SkRefCntBase

Classes

struct  List
 
struct  Register
 

Public Member Functions

SkVector getAdvance (SkGlyphID) const
 
void getFontMetrics (SkFontMetrics *metrics)
 
SkPath getPath (SkGlyphID glyph)
 
- Public Member Functions inherited from SkTypeface
SkFontStyle fontStyle () const
 
bool isBold () const
 
bool isItalic () const
 
bool isFixedPitch () const
 
int getVariationDesignPosition (SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const
 
int getVariationDesignParameters (SkFontParameters::Variation::Axis parameters[], int parameterCount) const
 
SkTypefaceID uniqueID () const
 
sk_sp< SkTypefacemakeClone (const SkFontArguments &) const
 
void serialize (SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
 
sk_sp< SkDataserialize (SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
 
void unicharsToGlyphs (const SkUnichar uni[], int count, SkGlyphID glyphs[]) const
 
int textToGlyphs (const void *text, size_t byteLength, SkTextEncoding encoding, SkGlyphID glyphs[], int maxGlyphCount) const
 
SkGlyphID unicharToGlyph (SkUnichar unichar) const
 
int countGlyphs () const
 
int countTables () const
 
int getTableTags (SkFontTableTag tags[]) const
 
size_t getTableSize (SkFontTableTag) const
 
size_t getTableData (SkFontTableTag tag, size_t offset, size_t length, void *data) const
 
sk_sp< SkDatacopyTableData (SkFontTableTag tag) const
 
int getUnitsPerEm () const
 
bool getKerningPairAdjustments (const SkGlyphID glyphs[], int count, int32_t adjustments[]) const
 
LocalizedStringscreateFamilyNameIterator () const
 
void getFamilyName (SkString *name) const
 
bool getPostScriptName (SkString *name) const
 
std::unique_ptr< SkStreamAssetopenStream (int *ttcIndex) const
 
std::unique_ptr< SkStreamAssetopenExistingStream (int *ttcIndex) const
 
std::unique_ptr< SkScalerContextcreateScalerContext (const SkScalerContextEffects &, const SkDescriptor *) const
 
SkRect getBounds () const
 
void filterRec (SkScalerContextRec *rec) const
 
void getFontDescriptor (SkFontDescriptor *desc, bool *isLocal) const
 
void * internal_private_getCTFontRef () const
 
- Public Member Functions inherited from SkWeakRefCnt
 SkWeakRefCnt ()
 
 ~SkWeakRefCnt () override
 
bool try_ref () const
 
void weak_ref () const
 
void weak_unref () const
 
bool weak_expired () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static const ListTypefaces ()
 
- Static Public Member Functions inherited from SkTypeface
static bool Equal (const SkTypeface *facea, const SkTypeface *faceb)
 
static sk_sp< SkTypefaceMakeEmpty ()
 
static sk_sp< SkTypefaceMakeDeserialize (SkStream *, sk_sp< SkFontMgr > lastResortMgr)
 
static void Register (FactoryId id, sk_sp< SkTypeface >(*make)(std::unique_ptr< SkStreamAsset >, const SkFontArguments &))
 

Protected Member Functions

std::unique_ptr< SkScalerContextonCreateScalerContext (const SkScalerContextEffects &, const SkDescriptor *desc) const override
 
void onFilterRec (SkScalerContextRec *rec) const override
 
void getGlyphToUnicodeMap (SkUnichar *glyphToUnicode) const override
 
std::unique_ptr< SkAdvancedTypefaceMetricsonGetAdvancedMetrics () const override
 
std::unique_ptr< SkStreamAssetonOpenStream (int *ttcIndex) const override
 
sk_sp< SkTypefaceonMakeClone (const SkFontArguments &args) const override
 
void onGetFontDescriptor (SkFontDescriptor *desc, bool *serialize) const override
 
void onCharsToGlyphs (const SkUnichar *chars, int count, SkGlyphID glyphs[]) const override
 
int onCountGlyphs () const override
 
void getPostScriptGlyphNames (SkString *) const override
 
int onGetUPEM () const override
 
void onGetFamilyName (SkString *familyName) const override
 
bool onGetPostScriptName (SkString *) const override
 
SkTypeface::LocalizedStringsonCreateFamilyNameIterator () const override
 
bool onGlyphMaskNeedsCurrentColor () const override
 
int onGetVariationDesignPosition (SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const override
 
int onGetVariationDesignParameters (SkFontParameters::Variation::Axis parameters[], int parameterCount) const override
 
int onGetTableTags (SkFontTableTag tags[]) const override
 
size_t onGetTableData (SkFontTableTag tag, size_t offset, size_t length, void *data) const override
 
- Protected Member Functions inherited from SkTypeface
 SkTypeface (const SkFontStyle &style, bool isFixedPitch=false)
 
 ~SkTypeface () override
 
void setIsFixedPitch (bool isFixedPitch)
 
void setFontStyle (SkFontStyle style)
 
virtual std::unique_ptr< SkStreamAssetonOpenExistingStream (int *ttcIndex) const
 
virtual bool onGetKerningPairAdjustments (const SkGlyphID glyphs[], int count, int32_t adjustments[]) const
 
virtual sk_sp< SkDataonCopyTableData (SkFontTableTag) const
 
virtual bool onComputeBounds (SkRect *) const
 
virtual void * onGetCTFontRef () const
 
- Protected Member Functions inherited from SkWeakRefCnt
virtual void weak_dispose () const
 

Friends

class SkTestScalerContext
 

Additional Inherited Members

- Public Types inherited from SkTypeface
enum class  SerializeBehavior { kDoIncludeData , kDontIncludeData , kIncludeDataIfLocal }
 
using FactoryId = SkFourByteTag
 

Detailed Description

Definition at line 65 of file TestTypeface.h.

Member Function Documentation

◆ getAdvance()

SkVector TestTypeface::getAdvance ( SkGlyphID  glyphID) const

Definition at line 131 of file TestTypeface.cpp.

131 {
132 glyphID = glyphID < fTestFont->fCharCodesCount ? glyphID : 0;
133
134 // TODO(benjaminwagner): Update users to use floats.
135 return {SkFixedToFloat(fTestFont->fWidths[glyphID]), 0};
136}
#define SkFixedToFloat(x)
Definition SkFixed.h:41

◆ getFontMetrics()

void TestTypeface::getFontMetrics ( SkFontMetrics metrics)

Definition at line 138 of file TestTypeface.cpp.

138{ *metrics = fTestFont->fMetrics; }

◆ getGlyphToUnicodeMap()

void TestTypeface::getGlyphToUnicodeMap ( SkUnichar glyphToUnicode) const
overrideprotectedvirtual

Implements SkTypeface.

Definition at line 149 of file TestTypeface.cpp.

149 {
150 unsigned glyphCount = fTestFont->fCharCodesCount;
151 for (unsigned gid = 0; gid < glyphCount; ++gid) {
152 glyphToUnicode[gid] = SkTo<SkUnichar>(fTestFont->fCharCodes[gid]);
153 }
154}

◆ getPath()

SkPath TestTypeface::getPath ( SkGlyphID  glyph)

Definition at line 140 of file TestTypeface.cpp.

140 {
141 glyphID = glyphID < fTestFont->fCharCodesCount ? glyphID : 0;
142 return fTestFont->fPaths[glyphID];
143}

◆ getPostScriptGlyphNames()

void TestTypeface::getPostScriptGlyphNames ( SkString ) const
inlineoverrideprotectedvirtual

Implements SkTypeface.

Definition at line 105 of file TestTypeface.h.

105{}

◆ onCharsToGlyphs()

void TestTypeface::onCharsToGlyphs ( const SkUnichar chars,
int  count,
SkGlyphID  glyphs[] 
) const
overrideprotectedvirtual

Implements SkTypeface.

Definition at line 231 of file TestTypeface.cpp.

231 {
232 for (int i = 0; i < count; ++i) {
233 glyphs[i] = fTestFont->glyphForUnichar(uni[i]);
234 }
235}
uint16_t glyphs[5]
int count
SkGlyphID glyphForUnichar(SkUnichar charCode) const

◆ onCountGlyphs()

int TestTypeface::onCountGlyphs ( ) const
inlineoverrideprotectedvirtual

Implements SkTypeface.

Definition at line 103 of file TestTypeface.h.

103{ return (int)fTestFont->fCharCodesCount; }

◆ onCreateFamilyNameIterator()

SkTypeface::LocalizedStrings * TestTypeface::onCreateFamilyNameIterator ( ) const
overrideprotectedvirtual

Returns an iterator over the family names in the font.

Implements SkTypeface.

Definition at line 241 of file TestTypeface.cpp.

241 {
242 SkString familyName(fTestFont->fName);
243 SkString language("und"); // undetermined
244 return new SkOTUtils::LocalizedStrings_SingleName(familyName, language);
245}

◆ onCreateScalerContext()

std::unique_ptr< SkScalerContext > TestTypeface::onCreateScalerContext ( const SkScalerContextEffects effects,
const SkDescriptor desc 
) const
overrideprotectedvirtual

Implements SkTypeface.

Definition at line 291 of file TestTypeface.cpp.

293{
294 return std::make_unique<SkTestScalerContext>(
295 sk_ref_sp(const_cast<TestTypeface*>(this)), effects, desc);
296}
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381

◆ onFilterRec()

void TestTypeface::onFilterRec ( SkScalerContextRec rec) const
overrideprotectedvirtual

Implements SkTypeface.

Definition at line 145 of file TestTypeface.cpp.

145 {
147}
@ kNone
glyph outlines unchanged
void setHinting(SkFontHinting)

◆ onGetAdvancedMetrics()

std::unique_ptr< SkAdvancedTypefaceMetrics > TestTypeface::onGetAdvancedMetrics ( ) const
overrideprotectedvirtual

Implements SkTypeface.

Definition at line 156 of file TestTypeface.cpp.

156 { // pdf only
157 std::unique_ptr<SkAdvancedTypefaceMetrics>info(new SkAdvancedTypefaceMetrics);
158 info->fPostScriptName.set(fTestFont->fName);
159 return info;
160}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213

◆ onGetFamilyName()

void TestTypeface::onGetFamilyName ( SkString familyName) const
overrideprotectedvirtual

Returns the family name of the typeface as known by its font manager. This name may or may not be produced by the family name iterator.

Implements SkTypeface.

Definition at line 237 of file TestTypeface.cpp.

237{ *familyName = fTestFont->fName; }

◆ onGetFontDescriptor()

void TestTypeface::onGetFontDescriptor ( SkFontDescriptor desc,
bool *  serialize 
) const
overrideprotectedvirtual

Implements SkTypeface.

Definition at line 219 of file TestTypeface.cpp.

219 {
220 desc->setFamilyName(fTestFont->fName);
221 desc->setStyle(this->fontStyle());
222 desc->setFactoryId(FactoryId);
223 *serialize = true;
224}
void setFactoryId(SkTypeface::FactoryId factoryId)
SkFontStyle fontStyle() const
Definition SkTypeface.h:55
void serialize(SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const

◆ onGetPostScriptName()

bool TestTypeface::onGetPostScriptName ( SkString ) const
overrideprotectedvirtual

Implements SkTypeface.

Definition at line 239 of file TestTypeface.cpp.

239{ return false; }

◆ onGetTableData()

size_t TestTypeface::onGetTableData ( SkFontTableTag  tag,
size_t  offset,
size_t  length,
void *  data 
) const
inlineoverrideprotectedvirtual

Implements SkTypeface.

Definition at line 127 of file TestTypeface.h.

130 {
131 return 0;
132 }

◆ onGetTableTags()

int TestTypeface::onGetTableTags ( SkFontTableTag  tags[]) const
inlineoverrideprotectedvirtual

Implements SkTypeface.

Definition at line 125 of file TestTypeface.h.

125{ return 0; }

◆ onGetUPEM()

int TestTypeface::onGetUPEM ( ) const
inlineoverrideprotectedvirtual

Implements SkTypeface.

Definition at line 107 of file TestTypeface.h.

107{ return 2048; }

◆ onGetVariationDesignParameters()

int TestTypeface::onGetVariationDesignParameters ( SkFontParameters::Variation::Axis  parameters[],
int  parameterCount 
) const
inlineoverrideprotectedvirtual

Implements SkTypeface.

Definition at line 120 of file TestTypeface.h.

121 {
122 return 0;
123 }

◆ onGetVariationDesignPosition()

int TestTypeface::onGetVariationDesignPosition ( SkFontArguments::VariationPosition::Coordinate  coordinates[],
int  coordinateCount 
) const
inlineoverrideprotectedvirtual

Implements SkTypeface.

Definition at line 115 of file TestTypeface.h.

116 {
117 return 0;
118 }

◆ onGlyphMaskNeedsCurrentColor()

bool TestTypeface::onGlyphMaskNeedsCurrentColor ( ) const
inlineoverrideprotectedvirtual

Implements SkTypeface.

Definition at line 113 of file TestTypeface.h.

113{ return false; }

◆ onMakeClone()

sk_sp< SkTypeface > TestTypeface::onMakeClone ( const SkFontArguments args) const
inlineoverrideprotectedvirtual

Implements SkTypeface.

Definition at line 95 of file TestTypeface.h.

95 {
96 return sk_ref_sp(this);
97 }

◆ onOpenStream()

std::unique_ptr< SkStreamAsset > TestTypeface::onOpenStream ( int ttcIndex) const
overrideprotectedvirtual

Implements SkTypeface.

Definition at line 165 of file TestTypeface.cpp.

165 {
168
170 this->getFamilyName(&name);
171 SkFontStyle style = this->fontStyle();
172
173 wstream.writePackedUInt(name.size());
174 wstream.write(name.c_str(), name.size());
175 wstream.writeScalar(style.weight());
176 wstream.writeScalar(style.width());
177 wstream.writePackedUInt(style.slant());
178
179 *ttcIndex = 0;
180 return wstream.detachAsStream();
181}
static const char gHeaderString[]
static constexpr size_t kHeaderSize
std::unique_ptr< SkStreamAsset > detachAsStream()
Definition SkStream.cpp:876
bool write(const void *buffer, size_t size) override
Definition SkStream.cpp:535
Slant slant() const
Definition SkFontStyle.h:64
int width() const
Definition SkFontStyle.h:63
int weight() const
Definition SkFontStyle.h:62
void getFamilyName(SkString *name) const
bool writePackedUInt(size_t)
Definition SkStream.cpp:122
bool writeScalar(SkScalar)
Definition SkStream.cpp:109
const char * name
Definition fuchsia.cc:50

◆ Typefaces()

const TestTypeface::List & TestTypeface::Typefaces ( )
static

Definition at line 43 of file TestTypeface.cpp.

43 {
44 static List list = []() -> List {
46 for (const auto& sub : gSubFonts) {
47 List::Family* existingFamily = nullptr;
48 for (auto& family : list.families) {
49 if (strcmp(family.name, sub.fFamilyName) == 0) {
50 existingFamily = &family;
51 break;
52 }
53 }
54 if (!existingFamily) {
55 existingFamily = &list.families.emplace_back();
56 existingFamily->name = sub.fFamilyName;
57 }
58
59 auto font = sk_make_sp<SkTestFont>(sub.fFont);
60 sk_sp<SkTypeface> typeface(new TestTypeface(std::move(font), sub.fStyle));
61 bool isDefault = (&sub - gSubFonts == gDefaultFontIndex);
62 existingFamily->faces.emplace_back(
63 List::Family::Face{std::move(typeface), sub.fStyleName, isDefault});
64 }
65 return list;
66 }();
67 return list;
68}
font
Font Metadata and Metrics.
std::vector< Family > families

Friends And Related Symbol Documentation

◆ SkTestScalerContext

friend class SkTestScalerContext
friend

Definition at line 139 of file TestTypeface.h.


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