8 #ifndef SkTypeface_DEFINED
9 #define SkTypeface_DEFINED
18 #include "include/private/SkWeakRefCnt.h"
19 #include "include/private/base/SkOnce.h"
28 class SkFontDescriptor;
29 class SkScalerContext;
34 struct SkAdvancedTypefaceMetrics;
35 struct SkScalerContextEffects;
36 struct SkScalerContextRec;
82 int coordinateCount)
const;
96 int parameterCount)
const;
108 #if !defined(SK_DISABLE_LEGACY_DEFAULT_TYPEFACE)
125 #if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
133 #if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
142 #if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
150 #if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
191 #if !defined(SK_DISABLE_LEGACY_FONTMGR_REFDEFAULT)
206 SkGlyphID glyphs[],
int maxGlyphCount)
const;
297 int32_t adjustments[])
const;
342 std::unique_ptr<SkStreamAsset>
openStream(
int* ttcIndex)
const;
358 const SkDescriptor*)
const;
369 this->onFilterRec(rec);
373 this->onGetFontDescriptor(desc, isLocal);
377 return this->onGetCTFontRef();
399 const SkDescriptor*)
const = 0;
401 friend class SkScalerContext;
415 virtual std::unique_ptr<SkStreamAsset>
onOpenStream(
int* ttcIndex)
const = 0;
423 int coordinateCount)
const = 0;
435 int32_t adjustments[])
const;
448 size_t length,
void* data)
const = 0;
460 bool glyphMaskNeedsCurrentColor()
const;
461 friend class SkStrikeServerImpl;
462 friend class SkTypefaceProxyPrototype;
465 std::unique_ptr<SkAdvancedTypefaceMetrics> getAdvancedMetrics()
const;
466 friend class SkRandomTypeface;
467 friend class SkPDFFont;
479 static SkTypeface* GetDefaultTypeface(Style style = SkTypeface::kNormal);
481 friend class SkFontPriv;
482 friend class SkPaintPriv;
489 mutable SkOnce fBoundsOnce;
492 using INHERITED = SkWeakRefCnt;
@ kNormal
glyph outlines modified to improve constrast
SkTextEncoding
Definition: SkFontTypes.h:11
uint32_t SkFontTableTag
Machine endian.
Definition: SkTypeface.h:41
uint32_t SkTypefaceID
Definition: SkTypeface.h:38
int32_t SkUnichar
32 bit integer to hold a unicode value
Definition: SkTypes.h:167
uint16_t SkGlyphID
16 bit unsigned integer to hold a glyph index
Definition: SkTypes.h:171
uint32_t SkFourByteTag
Definition: SkTypes.h:158
SkData holds an immutable data buffer.
Definition: SkData.h:25
Definition: SkFontMgr.h:36
Definition: SkFontStyle.h:16
@ kSemiBold_Weight
Definition: SkFontStyle.h:25
@ kUpright_Slant
Definition: SkFontStyle.h:45
SkFont controls options applied when drawing and measuring text.
Definition: SkFont.h:36
SkStreamAsset is a SkStreamSeekable for which getLength is required.
Definition: SkStream.h:186
SkStream – abstraction for a source of bytes.
Definition: SkStream.h:29
Light weight class for managing strings.
Definition: SkString.h:118
Definition: SkTypeface.h:303
virtual bool next(LocalizedString *localizedString)=0
LocalizedStrings()=default
virtual ~LocalizedStrings()
Definition: SkTypeface.h:306
void unref()
Definition: SkTypeface.h:308
The SkTypeface class specifies the typeface and intrinsic style of a font.
Definition: SkTypeface.h:52
sk_sp< SkTypeface > makeClone(const SkFontArguments &) const
Return a new typeface based on this typeface but parameterized as specified in the SkFontArguments.
int countGlyphs() const
Return the number of glyphs in the typeface.
virtual std::unique_ptr< SkStreamAsset > onOpenExistingStream(int *ttcIndex) const
void * internal_private_getCTFontRef() const
Definition: SkTypeface.h:376
static sk_sp< SkTypeface > MakeDeserialize(SkStream *)
Given the data previously written by serialize(), return a new instance of a typeface referring to th...
static sk_sp< SkTypeface > MakeFromName(const char familyName[], SkFontStyle fontStyle)
Creates a new reference to the typeface that most closely matches the requested familyName and fontSt...
SkRect getBounds() const
Return a rectangle (scaled to 1-pt) that represents the union of the bounds of all of the glyphs,...
virtual void getPostScriptGlyphNames(SkString *) const =0
virtual LocalizedStrings * onCreateFamilyNameIterator() const =0
Returns an iterator over the family names in the font.
SkTypefaceID uniqueID() const
Return a 32bit value for this typeface, unique for the underlying font data.
Definition: SkTypeface.h:101
LocalizedStrings * createFamilyNameIterator() const
Returns an iterator which will attempt to enumerate all of the family names specified by the font.
static sk_sp< SkTypeface > MakeDeserialize(SkStream *, sk_sp< SkFontMgr > lastResortMgr)
virtual bool onComputeBounds(SkRect *) const
void setFontStyle(SkFontStyle style)
Sets the font style.
Definition: SkTypeface.h:395
static void Register(FactoryId id, sk_sp< SkTypeface >(*make)(std::unique_ptr< SkStreamAsset >, const SkFontArguments &))
std::unique_ptr< SkStreamAsset > openStream(int *ttcIndex) const
Return a stream for the contents of the font data, or NULL on failure.
void getFontDescriptor(SkFontDescriptor *desc, bool *isLocal) const
Definition: SkTypeface.h:372
int getUnitsPerEm() const
Return the units-per-em value for this typeface, or zero if there is an error.
static sk_sp< SkTypeface > MakeFromFile(const char path[], int index=0)
Return a new typeface given a file.
void setIsFixedPitch(bool isFixedPitch)
Sets the fixedPitch bit.
Definition: SkTypeface.h:393
void getFamilyName(SkString *name) const
Return the family name for this typeface.
SkFontStyle fontStyle() const
Returns the typeface's intrinsic style attributes.
Definition: SkTypeface.h:55
virtual void getGlyphToUnicodeMap(SkUnichar *dstArray) const =0
virtual int onCountGlyphs() const =0
void serialize(SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
Write a unique signature to a stream, sufficient to reconstruct a typeface referencing the same font ...
virtual int onGetTableTags(SkFontTableTag tags[]) const =0
int getVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], int parameterCount) const
Copy into 'parameters' (allocated by the caller) the design variation parameters.
int textToGlyphs(const void *text, size_t byteLength, SkTextEncoding encoding, SkGlyphID glyphs[], int maxGlyphCount) const
virtual std::unique_ptr< SkAdvancedTypefaceMetrics > onGetAdvancedMetrics() const =0
bool isFixedPitch() const
Returns true if the typeface claims to be fixed-pitch.
Definition: SkTypeface.h:68
bool getKerningPairAdjustments(const SkGlyphID glyphs[], int count, int32_t adjustments[]) const
Given a run of glyphs, return the associated horizontal adjustments.
int getTableTags(SkFontTableTag tags[]) const
Copy into tags[] (allocated by the caller) the list of table tags in the font, and return the number.
void filterRec(SkScalerContextRec *rec) const
Definition: SkTypeface.h:368
virtual void onGetFontDescriptor(SkFontDescriptor *, bool *isLocal) const =0
size_t getTableSize(SkFontTableTag) const
Given a table tag, return the size of its contents, or 0 if not present.
virtual std::unique_ptr< SkScalerContext > onCreateScalerContext(const SkScalerContextEffects &, const SkDescriptor *) const =0
bool isBold() const
Returns true if style() has the kBold bit set.
Definition: SkTypeface.h:60
static sk_sp< SkTypeface > MakeDefault()
Returns the default normal typeface, which is never nullptr.
int getVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const
Copy into 'coordinates' (allocated by the caller) the design variation coordinates.
static sk_sp< SkTypeface > MakeFromData(sk_sp< SkData >, int index=0)
Return a new typeface given a SkData and TTC index (pass 0 for none).
bool getPostScriptName(SkString *name) const
Return the PostScript name for this typeface.
virtual size_t onGetTableData(SkFontTableTag, size_t offset, size_t length, void *data) const =0
virtual sk_sp< SkTypeface > onMakeClone(const SkFontArguments &) const =0
virtual bool onGetPostScriptName(SkString *) const =0
SerializeBehavior
A typeface can serialize just a descriptor (names, etc.), or it can also include the actual font data...
Definition: SkTypeface.h:167
std::unique_ptr< SkScalerContext > createScalerContext(const SkScalerContextEffects &, const SkDescriptor *) const
Return a scalercontext for the given descriptor.
sk_sp< SkData > copyTableData(SkFontTableTag tag) const
Return an immutable copy of the requested font table, or nullptr if that table was not found.
static sk_sp< SkTypeface > MakeEmpty()
Returns a non-null typeface which contains no glyphs.
virtual void onGetFamilyName(SkString *familyName) const =0
Returns the family name of the typeface as known by its font manager.
virtual void onFilterRec(SkScalerContextRec *) const =0
virtual bool onGlyphMaskNeedsCurrentColor() const =0
int countTables() const
Return the number of tables in the font.
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset > stream, int index=0)
Return a new typeface given a stream and TTC index(pass 0 for none).
virtual int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], int parameterCount) const =0
virtual void * onGetCTFontRef() const
Definition: SkTypeface.h:453
SkFourByteTag FactoryId
Definition: SkTypeface.h:381
size_t getTableData(SkFontTableTag tag, size_t offset, size_t length, void *data) const
Copy the contents of a table into data (allocated by the caller).
bool isItalic() const
Returns true if style() has the kItalic bit set.
Definition: SkTypeface.h:63
std::unique_ptr< SkStreamAsset > openExistingStream(int *ttcIndex) const
Return a stream for the contents of the font data.
static bool Equal(const SkTypeface *facea, const SkTypeface *faceb)
Returns true if the two typefaces reference the same underlying font, handling either being null (tre...
SkGlyphID unicharToGlyph(SkUnichar unichar) const
Return the glyphID that corresponds to the specified unicode code-point (in UTF32 encoding).
virtual void onCharsToGlyphs(const SkUnichar *chars, int count, SkGlyphID glyphs[]) const =0
virtual int onGetUPEM() const =0
void unicharsToGlyphs(const SkUnichar uni[], int count, SkGlyphID glyphs[]) const
Given an array of UTF32 character codes, return their corresponding glyph IDs.
SkTypeface(const SkFontStyle &style, bool isFixedPitch=false)
virtual std::unique_ptr< SkStreamAsset > onOpenStream(int *ttcIndex) const =0
sk_sp< SkData > serialize(SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
Same as serialize(SkWStream*, ...) but returns the serialized data in SkData, instead of writing it t...
virtual bool onGetKerningPairAdjustments(const SkGlyphID glyphs[], int count, int32_t adjustments[]) const
virtual int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const =0
virtual sk_sp< SkData > onCopyTableData(SkFontTableTag) const
Definition: SkStream.h:218
Definition: SkFontArguments.h:18
Represents a set of actual arguments for a font.
Definition: SkFontArguments.h:16
Definition: SkFontParameters.h:17
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582
Definition: SkTypeface.h:299
SkString fString
Definition: SkTypeface.h:300
SkString fLanguage
Definition: SkTypeface.h:301