 |
Skia
2D Graphics Library
|
Go to the documentation of this file.
8 #ifndef SkTypeface_DEFINED
9 #define SkTypeface_DEFINED
17 #include "include/private/SkOnce.h"
18 #include "include/private/SkWeakRefCnt.h"
23 class SkFontDescriptor;
24 class SkScalerContext;
28 struct SkAdvancedTypefaceMetrics;
29 struct SkScalerContextEffects;
30 struct SkScalerContextRec;
75 int coordinateCount)
const;
89 int parameterCount)
const;
272 int32_t adjustments[])
const;
317 std::unique_ptr<SkStreamAsset>
openStream(
int* ttcIndex)
const;
324 const SkDescriptor*)
const;
335 this->onFilterRec(rec);
339 this->onGetFontDescriptor(desc, isLocal);
343 return this->onGetCTFontRef();
359 const SkDescriptor*)
const = 0;
361 friend class SkScalerContext;
375 virtual std::unique_ptr<SkStreamAsset>
onOpenStream(
int* ttcIndex)
const = 0;
379 int coordinateCount)
const = 0;
391 int32_t adjustments[])
const;
404 size_t length,
void* data)
const = 0;
413 std::unique_ptr<SkAdvancedTypefaceMetrics> getAdvancedMetrics()
const;
414 friend class SkRandomTypeface;
415 friend class SkPDFFont;
427 static SkTypeface* GetDefaultTypeface(Style style = SkTypeface::kNormal);
429 friend class SkFontPriv;
430 friend class SkPaintPriv;
437 mutable SkOnce fBoundsOnce;
440 using INHERITED = SkWeakRefCnt;
bool isItalic() const
Returns true if style() has the kItalic bit set.
Definition: SkTypeface.h:56
@ kNormal
glyph outlines modified to improve constrast
uint16_t SkGlyphID
16 bit unsigned integer to hold a glyph index
Definition: SkTypes.h:556
Definition: SkFontStyle.h:14
std::unique_ptr< SkScalerContext > createScalerContext(const SkScalerContextEffects &, const SkDescriptor *) const
Return a scalercontext for the given descriptor.
virtual std::unique_ptr< SkScalerContext > onCreateScalerContext(const SkScalerContextEffects &, const SkDescriptor *) const =0
virtual void onGetFontDescriptor(SkFontDescriptor *, bool *isLocal) const =0
void getFamilyName(SkString *name) const
Return the family name for this typeface.
Definition: SkTypeface.h:274
virtual sk_sp< SkTypeface > onMakeClone(const SkFontArguments &) const =0
int getUnitsPerEm() const
Return the units-per-em value for this typeface, or zero if there is an error.
int getTableTags(SkFontTableTag tags[]) const
Copy into tags[] (allocated by the caller) the list of table tags in the font, and return the number.
int countGlyphs() const
Return the number of glyphs in the typeface.
virtual ~LocalizedStrings()
Definition: SkTypeface.h:281
@ kSemiBold_Weight
Definition: SkFontStyle.h:23
SkTypeface(const SkFontStyle &style, bool isFixedPitch=false)
virtual std::unique_ptr< SkStreamAsset > onOpenStream(int *ttcIndex) const =0
SkFontID uniqueID() const
Return a 32bit value for this typeface, unique for the underlying font data.
Definition: SkTypeface.h:94
virtual int onGetTableTags(SkFontTableTag tags[]) const =0
LocalizedStrings()=default
virtual int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], int parameterCount) const =0
virtual LocalizedStrings * onCreateFamilyNameIterator() const =0
Returns an iterator over the family names in the font.
bool getPostScriptName(SkString *name) const
Return the PostScript name for this typeface.
virtual void onFilterRec(SkScalerContextRec *) const =0
SkData holds an immutable data buffer.
Definition: SkData.h:22
SkStream – abstraction for a source of bytes.
Definition: SkStream.h:41
void filterRec(SkScalerContextRec *rec) const
Definition: SkTypeface.h:334
Definition: SkFontArguments.h:17
SkFontStyle fontStyle() const
Returns the typeface's intrinsic style attributes.
Definition: SkTypeface.h:48
void serialize(SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
Write a unique signature to a stream, sufficient to reconstruct a typeface referencing the same font ...
virtual bool onGetPostScriptName(SkString *) const =0
Definition: SkTypeface.h:45
SkString fLanguage
Definition: SkTypeface.h:276
static sk_sp< SkTypeface > MakeDefault()
Returns the default normal typeface, which is never nullptr.
SerializeBehavior
A typeface can serialize just a descriptor (names, etc.), or it can also include the actual font data...
Definition: SkTypeface.h:150
void getFontDescriptor(SkFontDescriptor *desc, bool *isLocal) const
Definition: SkTypeface.h:338
#define SK_API
Definition: SkTypes.h:181
virtual void onGetFamilyName(SkString *familyName) const =0
Returns the family name of the typeface as known by its font manager.
uint32_t SkFontTableTag
Machine endian.
Definition: SkTypeface.h:34
Definition: SkTypeface.h:278
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 getKerningPairAdjustments(const SkGlyphID glyphs[], int count, int32_t adjustments[]) const
Given a run of glyphs, return the associated horizontal adjustments.
sk_sp< SkTypeface > makeClone(const SkFontArguments &) const
Return a new typeface based on this typeface but parameterized as specified in the SkFontArguments.
virtual int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const =0
static SkFontID UniqueID(const SkTypeface *face)
Return the uniqueID for the specified typeface.
sk_sp< SkData > serialize(SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
Same as serialize(SkWStream*, ...) but returns the serialized data in SkData, instead of writing it t...
SkRect getBounds() const
Return a rectangle (scaled to 1-pt) that represents the union of the bounds of all of the glyphs,...
void * internal_private_getCTFontRef() const
Definition: SkTypeface.h:342
static sk_sp< SkTypeface > MakeFromData(sk_sp< SkData >, int index=0)
Return a new typeface given a SkData.
SkString fString
Definition: SkTypeface.h:275
SkGlyphID unicharToGlyph(SkUnichar unichar) const
Return the glyphID that corresponds to the specified unicode code-point (in UTF32 encoding).
int32_t SkUnichar
32 bit integer to hold a unicode value
Definition: SkTypes.h:552
virtual size_t onGetTableData(SkFontTableTag, size_t offset, size_t length, void *data) const =0
SkStreamAsset is a SkStreamSeekable for which getLength is required.
Definition: SkStream.h:195
int getVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const
Copy into 'coordinates' (allocated by the caller) the design variation coordinates.
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...
static sk_sp< SkTypeface > MakeDeserialize(SkStream *)
Given the data previously written by serialize(), return a new instance of a typeface referring to th...
uint32_t SkFontID
Definition: SkTypeface.h:30
virtual void * onGetCTFontRef() const
Definition: SkTypeface.h:409
LocalizedStrings * createFamilyNameIterator() const
Returns an iterator which will attempt to enumerate all of the family names specified by the font.
void setFontStyle(SkFontStyle style)
Sets the font style.
Definition: SkTypeface.h:355
virtual int onCountGlyphs() const =0
virtual bool onComputeBounds(SkRect *) const
Definition: SkStream.h:227
Definition: SkString.h:116
int countTables() const
Return the number of tables in the font.
std::unique_ptr< SkStreamAsset > openStream(int *ttcIndex) const
Return a stream for the contents of the font data, or NULL on failure.
virtual void onCharsToGlyphs(const SkUnichar *chars, int count, SkGlyphID glyphs[]) const =0
void unicharsToGlyphs(const SkUnichar uni[], int count, SkGlyphID glyphs[]) const
Given an array of UTF32 character codes, return their corresponding glyph IDs.
static sk_sp< SkTypeface > MakeFromFile(const char path[], int index=0)
Return a new typeface given a file.
void unref()
Definition: SkTypeface.h:283
virtual void getGlyphToUnicodeMap(SkUnichar *dstArray) const =0
virtual bool onGetKerningPairAdjustments(const SkGlyphID glyphs[], int count, int32_t adjustments[]) const
virtual void getPostScriptGlyphNames(SkString *) const =0
sk_sp< SkData > copyTableData(SkFontTableTag tag) const
Return an immutable copy of the requested font table, or nullptr if that table was not found.
bool isBold() const
Returns true if style() has the kBold bit set.
Definition: SkTypeface.h:53
void setIsFixedPitch(bool isFixedPitch)
Sets the fixedPitch bit.
Definition: SkTypeface.h:353
Definition: SkFontParameters.h:17
virtual std::unique_ptr< SkAdvancedTypefaceMetrics > onGetAdvancedMetrics() const =0
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...
virtual bool next(LocalizedString *localizedString)=0
static sk_sp< SkTypeface > MakeFromStream(std::unique_ptr< SkStreamAsset > stream, int index=0)
Return a new typeface given a stream.
virtual sk_sp< SkData > onCopyTableData(SkFontTableTag) const
int getVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], int parameterCount) const
Copy into 'parameters' (allocated by the caller) the design variation parameters.
Represents a set of actual arguments for a font.
Definition: SkFontArguments.h:15
@ kUpright_Slant
Definition: SkFontStyle.h:43
bool isFixedPitch() const
Returns true if the typeface claims to be fixed-pitch.
Definition: SkTypeface.h:61
size_t getTableSize(SkFontTableTag) const
Given a table tag, return the size of its contents, or 0 if not present.
virtual int onGetUPEM() const =0