Flutter Engine
The Flutter Engine
|
#include <SkTypeface.h>
Classes | |
struct | LocalizedString |
class | LocalizedStrings |
Public Types | |
enum class | SerializeBehavior { kDoIncludeData , kDontIncludeData , kIncludeDataIfLocal } |
using | FactoryId = SkFourByteTag |
Static Public Member Functions | |
static bool | Equal (const SkTypeface *facea, const SkTypeface *faceb) |
static sk_sp< SkTypeface > | MakeEmpty () |
static sk_sp< SkTypeface > | MakeDeserialize (SkStream *, sk_sp< SkFontMgr > lastResortMgr) |
static void | Register (FactoryId id, sk_sp< SkTypeface >(*make)(std::unique_ptr< SkStreamAsset >, const SkFontArguments &)) |
Protected Member Functions | |
SkTypeface (const SkFontStyle &style, bool isFixedPitch=false) | |
~SkTypeface () override | |
virtual sk_sp< SkTypeface > | onMakeClone (const SkFontArguments &) const =0 |
void | setIsFixedPitch (bool isFixedPitch) |
void | setFontStyle (SkFontStyle style) |
virtual std::unique_ptr< SkScalerContext > | onCreateScalerContext (const SkScalerContextEffects &, const SkDescriptor *) const =0 |
virtual void | onFilterRec (SkScalerContextRec *) const =0 |
virtual std::unique_ptr< SkAdvancedTypefaceMetrics > | onGetAdvancedMetrics () const =0 |
virtual void | getPostScriptGlyphNames (SkString *) const =0 |
virtual void | getGlyphToUnicodeMap (SkUnichar *dstArray) const =0 |
virtual std::unique_ptr< SkStreamAsset > | onOpenStream (int *ttcIndex) const =0 |
virtual std::unique_ptr< SkStreamAsset > | onOpenExistingStream (int *ttcIndex) const |
virtual bool | onGlyphMaskNeedsCurrentColor () const =0 |
virtual int | onGetVariationDesignPosition (SkFontArguments::VariationPosition::Coordinate coordinates[], int coordinateCount) const =0 |
virtual int | onGetVariationDesignParameters (SkFontParameters::Variation::Axis parameters[], int parameterCount) const =0 |
virtual void | onGetFontDescriptor (SkFontDescriptor *, bool *isLocal) const =0 |
virtual void | onCharsToGlyphs (const SkUnichar *chars, int count, SkGlyphID glyphs[]) const =0 |
virtual int | onCountGlyphs () const =0 |
virtual int | onGetUPEM () const =0 |
virtual bool | onGetKerningPairAdjustments (const SkGlyphID glyphs[], int count, int32_t adjustments[]) const |
virtual void | onGetFamilyName (SkString *familyName) const =0 |
virtual bool | onGetPostScriptName (SkString *) const =0 |
virtual LocalizedStrings * | onCreateFamilyNameIterator () const =0 |
virtual int | onGetTableTags (SkFontTableTag tags[]) const =0 |
virtual size_t | onGetTableData (SkFontTableTag, size_t offset, size_t length, void *data) const =0 |
virtual sk_sp< SkData > | onCopyTableData (SkFontTableTag) const |
virtual bool | onComputeBounds (SkRect *) const |
virtual void * | onGetCTFontRef () const |
Protected Member Functions inherited from SkWeakRefCnt | |
virtual void | weak_dispose () const |
Friends | |
class | SkScalerContext |
class | SkStrikeServerImpl |
class | SkTypefaceProxyPrototype |
class | SkRandomTypeface |
class | SkPDFFont |
class | SkFontPriv |
The SkTypeface class specifies the typeface and intrinsic style of a font. This is used in the paint, along with optionally algorithmic settings like textSize, textSkewX, textScaleX, kFakeBoldText_Mask, to specify how text appears when drawn (and measured).
Typeface objects are immutable, and so they can be shared between threads.
Definition at line 52 of file SkTypeface.h.
using SkTypeface::FactoryId = SkFourByteTag |
Definition at line 335 of file SkTypeface.h.
|
strong |
A typeface can serialize just a descriptor (names, etc.), or it can also include the actual font data (which can be large). This enum controls how serialize() decides what to serialize.
Enumerator | |
---|---|
kDoIncludeData | |
kDontIncludeData | |
kIncludeDataIfLocal |
Definition at line 124 of file SkTypeface.h.
|
explicitprotected |
Definition at line 56 of file SkTypeface.cpp.
|
overrideprotected |
Definition at line 59 of file SkTypeface.cpp.
sk_sp< SkData > SkTypeface::copyTableData | ( | SkFontTableTag | tag | ) | const |
Return an immutable copy of the requested font table, or nullptr if that table was not found. This can sometimes be faster than calling getTableData() twice: once to find the length, and then again to copy the data.
tag | The table tag whose contents are to be copied |
Definition at line 318 of file SkTypeface.cpp.
int SkTypeface::countGlyphs | ( | ) | const |
Return the number of glyphs in the typeface.
Definition at line 432 of file SkTypeface.cpp.
int SkTypeface::countTables | ( | ) | const |
Return the number of tables in the font.
Definition at line 301 of file SkTypeface.cpp.
SkTypeface::LocalizedStrings * SkTypeface::createFamilyNameIterator | ( | ) | const |
Returns an iterator which will attempt to enumerate all of the family names specified by the font. It is the caller's responsibility to unref() the returned pointer.
Definition at line 455 of file SkTypeface.cpp.
std::unique_ptr< SkScalerContext > SkTypeface::createScalerContext | ( | const SkScalerContextEffects & | effects, |
const SkDescriptor * | desc | ||
) | const |
Return a scalercontext for the given descriptor. It may return a stub scalercontext that will not crash, but will draw nothing.
Definition at line 350 of file SkTypeface.cpp.
|
static |
Returns true if the two typefaces reference the same underlying font, handling either being null (treating null as not equal to any font).
Definition at line 149 of file SkTypeface.cpp.
|
inline |
Definition at line 322 of file SkTypeface.h.
|
inline |
Returns the typeface's intrinsic style attributes.
Definition at line 55 of file SkTypeface.h.
SkRect SkTypeface::getBounds | ( | ) | const |
Return a rectangle (scaled to 1-pt) that represents the union of the bounds of all of the glyphs, but each one positioned at (0,). This may be conservatively large, and will not take into account any hinting or other size-specific adjustments.
Definition at line 507 of file SkTypeface.cpp.
void SkTypeface::getFamilyName | ( | SkString * | name | ) | const |
Return the family name for this typeface. It will always be returned encoded as UTF8, but the language of the name is whatever the host platform chooses.
Definition at line 459 of file SkTypeface.cpp.
|
inline |
Definition at line 326 of file SkTypeface.h.
|
protectedpure virtual |
Implemented in SkTypefaceProxy, SkTypeface_Fontations, SkTypeface_FreeType, SkRandomTypeface, TestEmptyTypeface, DWriteFontTypeface, and TestTypeface.
Definition at line 468 of file SkTypeface.cpp.
bool SkTypeface::getKerningPairAdjustments | ( | const SkGlyphID | glyphs[], |
int | count, | ||
int32_t | adjustments[] | ||
) | const |
Given a run of glyphs, return the associated horizontal adjustments. Adjustments are in "design units", which are integers relative to the typeface's units per em (see getUnitsPerEm).
Some typefaces are known to never support kerning. Calling this method with all zeros (e.g. getKerningPairAdustments(NULL, 0, NULL)) returns a boolean indicating if the typeface might support kerning. If it returns false, then it will always return false (no kerning) for all possible glyph runs. If it returns true, then it may return true for somne glyph runs.
If count is non-zero, then the glyphs parameter must point to at least [count] valid glyph IDs, and the adjustments parameter must be sized to at least [count - 1] entries. If the method returns true, then [count-1] entries in the adjustments array will be set. If the method returns false, then no kerning should be applied, and the adjustments array will be in an undefined state (possibly some values may have been written, but none of them should be interpreted as valid values).
Definition at line 441 of file SkTypeface.cpp.
|
protectedpure virtual |
Implemented in SkTypefaceProxy, SkTypeface_Fontations, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, TestTypeface, and SkTypeface_FreeType.
bool SkTypeface::getPostScriptName | ( | SkString * | name | ) | const |
Return the PostScript name for this typeface. Value may change based on variation parameters. Returns false if no PostScript name is available.
Definition at line 464 of file SkTypeface.cpp.
size_t SkTypeface::getTableData | ( | SkFontTableTag | tag, |
size_t | offset, | ||
size_t | length, | ||
void * | data | ||
) | const |
Copy the contents of a table into data (allocated by the caller). Note that the contents of the table will be in their native endian order (which for most truetype tables is big endian). If the table tag is not found, or there is an error copying the data, then 0 is returned. If this happens, it is possible that some or all of the memory pointed to by data may have been written to, even though an error has occured.
tag | The table tag whose contents are to be copied |
offset | The offset in bytes into the table's contents where the copy should start from. |
length | The number of bytes, starting at offset, of table data to copy. |
data | storage address where the table contents are copied to |
Definition at line 313 of file SkTypeface.cpp.
size_t SkTypeface::getTableSize | ( | SkFontTableTag | tag | ) | const |
Given a table tag, return the size of its contents, or 0 if not present
Definition at line 309 of file SkTypeface.cpp.
int SkTypeface::getTableTags | ( | SkFontTableTag | tags[] | ) | const |
Copy into tags[] (allocated by the caller) the list of table tags in the font, and return the number. This will be the same as CountTables() or 0 if an error occured. If tags == NULL, this only returns the count (the same as calling countTables()).
Definition at line 305 of file SkTypeface.cpp.
int SkTypeface::getUnitsPerEm | ( | ) | const |
Return the units-per-em value for this typeface, or zero if there is an error.
Definition at line 436 of file SkTypeface.cpp.
int SkTypeface::getVariationDesignParameters | ( | SkFontParameters::Variation::Axis | parameters[], |
int | parameterCount | ||
) | const |
Copy into 'parameters' (allocated by the caller) the design variation parameters.
parameters | the buffer into which to write the design variation parameters. |
coordinateCount | the number of entries available through 'parameters'. |
Definition at line 295 of file SkTypeface.cpp.
int SkTypeface::getVariationDesignPosition | ( | SkFontArguments::VariationPosition::Coordinate | coordinates[], |
int | coordinateCount | ||
) | const |
Copy into 'coordinates' (allocated by the caller) the design variation coordinates.
coordinates | the buffer into which to write the design variation coordinates. |
coordinateCount | the number of entries available through 'coordinates'. |
Definition at line 289 of file SkTypeface.cpp.
|
inline |
Definition at line 330 of file SkTypeface.h.
|
inline |
|
inline |
Returns true if the typeface claims to be fixed-pitch. This is a style bit, advance widths may vary even if this returns true.
Definition at line 68 of file SkTypeface.h.
|
inline |
sk_sp< SkTypeface > SkTypeface::makeClone | ( | const SkFontArguments & | args | ) | const |
Return a new typeface based on this typeface but parameterized as specified in the SkFontArguments. If the SkFontArguments does not supply an argument for a parameter in the font then the value from this typeface will be used as the value for that argument. If the cloned typeface would be exaclty the same as this typeface then this typeface may be ref'ed and returned. May return nullptr on failure.
Definition at line 190 of file SkTypeface.cpp.
|
static |
Given the data previously written by serialize(), return a new instance of a typeface referring to the same font. If that font is not available, return nullptr. Goes through all registered typeface factories and lastResortMgr (if non-null). Does not affect ownership of SkStream.
Definition at line 241 of file SkTypeface.cpp.
|
static |
Returns a non-null typeface which contains no glyphs.
Definition at line 145 of file SkTypeface.cpp.
|
protectedpure virtual |
Implemented in SkTypefaceProxy, SkTypeface_Fontations, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, and TestTypeface.
|
protectedvirtual |
Definition at line 516 of file SkTypeface.cpp.
|
protectedvirtual |
Reimplemented in SkTypeface_FreeType, and DWriteFontTypeface.
Definition at line 322 of file SkTypeface.cpp.
|
protectedpure virtual |
Implemented in SkTypefaceProxy, SkTypeface_Fontations, SkTypeface_FreeType, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, and TestTypeface.
|
protectedpure virtual |
Returns an iterator over the family names in the font.
Implemented in SkTypefaceProxy, SkTypeface_Fontations, SkTypeface_FreeType, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, and TestTypeface.
|
protectedpure virtual |
Implemented in SkTypeface_FreeType, DWriteFontTypeface, SkRandomTypeface, TestTypeface, SkTypefaceProxy, SkTypeface_Fontations, and TestEmptyTypeface.
|
protectedpure virtual |
|
protectedpure virtual |
|
inlineprotectedvirtual |
Reimplemented in SkTypefaceProxy.
Definition at line 407 of file SkTypeface.h.
|
protectedpure virtual |
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.
Implemented in SkTypefaceProxy, SkTypeface_FCI, SkTypeface_Custom, SkTypeface_fontconfig, SkTypeface_Fontations, SkTypeface_FreeTypeStream, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, and TestTypeface.
|
protectedpure virtual |
|
protectedvirtual |
Reimplemented in SkTypeface_FreeType.
Definition at line 496 of file SkTypeface.cpp.
|
protectedpure virtual |
Implemented in SkTypefaceProxy, SkTypeface_Fontations, SkTypeface_FreeType, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, and TestTypeface.
|
protectedpure virtual |
Implemented in TestTypeface, SkTypefaceProxy, SkTypeface_FreeType, DWriteFontTypeface, SkRandomTypeface, SkTypeface_Fontations, and TestEmptyTypeface.
|
protectedpure virtual |
Implemented in SkTypefaceProxy, SkTypeface_Fontations, SkTypeface_FreeType, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, and TestTypeface.
|
protectedpure virtual |
Implemented in SkTypefaceProxy, SkTypeface_Fontations, SkTypeface_FreeType, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, and TestTypeface.
|
protectedpure virtual |
Implemented in SkTypefaceProxy, SkTypeface_Fontations, SkTypeface_FreeType, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, and TestTypeface.
|
protectedpure virtual |
Implemented in SkTypefaceProxy, SkTypeface_Fontations, SkTypeface_FreeType, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, and TestTypeface.
|
protectedpure virtual |
Implemented in SkTypefaceProxy, SkTypeface_Fontations, SkTypeface_FreeType, DWriteFontTypeface, SkRandomTypeface, TestEmptyTypeface, and TestTypeface.
|
protectedpure virtual |
|
protectedvirtual |
Definition at line 501 of file SkTypeface.cpp.
|
protectedpure virtual |
std::unique_ptr< SkStreamAsset > SkTypeface::openExistingStream | ( | int * | ttcIndex | ) | const |
Return a stream for the contents of the font data. Returns nullptr on failure or if the font data isn't already available in stream form. Use when the stream can be used opportunistically but the calling code would prefer to fall back to table access if creating the stream would be expensive. Otherwise acts the same as openStream.
Definition at line 341 of file SkTypeface.cpp.
std::unique_ptr< SkStreamAsset > SkTypeface::openStream | ( | int * | ttcIndex | ) | const |
Return a stream for the contents of the font data, or NULL on failure. If ttcIndex is not null, it is set to the TrueTypeCollection index of this typeface within the stream, or 0 if the stream is not a collection. The caller is responsible for deleting the stream.
Definition at line 332 of file SkTypeface.cpp.
|
static |
Definition at line 196 of file SkTypeface.cpp.
sk_sp< SkData > SkTypeface::serialize | ( | SerializeBehavior | behavior = SerializeBehavior::kIncludeDataIfLocal | ) | const |
Same as serialize(SkWStream*, ...) but returns the serialized data in SkData, instead of writing it to a stream.
Definition at line 235 of file SkTypeface.cpp.
void SkTypeface::serialize | ( | SkWStream * | wstream, |
SerializeBehavior | behavior = SerializeBehavior::kIncludeDataIfLocal |
||
) | const |
Write a unique signature to a stream, sufficient to reconstruct a typeface referencing the same font when Deserialize is called.
Definition at line 202 of file SkTypeface.cpp.
|
inlineprotected |
Sets the font style. If used, must be called in the constructor.
Definition at line 349 of file SkTypeface.h.
|
inlineprotected |
Sets the fixedPitch bit. If used, must be called in the constructor.
Definition at line 347 of file SkTypeface.h.
int SkTypeface::textToGlyphs | ( | const void * | text, |
size_t | byteLength, | ||
SkTextEncoding | encoding, | ||
SkGlyphID | glyphs[], | ||
int | maxGlyphCount | ||
) | const |
Definition at line 407 of file SkTypeface.cpp.
Given an array of UTF32 character codes, return their corresponding glyph IDs.
chars | pointer to the array of UTF32 chars |
number | of chars and glyphs |
glyphs | returns the corresponding glyph IDs for each character. |
Definition at line 357 of file SkTypeface.cpp.
Return the glyphID that corresponds to the specified unicode code-point (in UTF32 encoding). If the unichar is not supported, returns 0.
This is a short-cut for calling unicharsToGlyphs().
Definition at line 363 of file SkTypeface.cpp.
|
inline |
Return a 32bit value for this typeface, unique for the underlying font data. Will never return 0.
Definition at line 101 of file SkTypeface.h.
|
friend |
Definition at line 423 of file SkTypeface.h.
|
friend |
Definition at line 421 of file SkTypeface.h.
|
friend |
Definition at line 420 of file SkTypeface.h.
|
friend |
Definition at line 355 of file SkTypeface.h.
|
friend |
Definition at line 415 of file SkTypeface.h.
|
friend |
Definition at line 416 of file SkTypeface.h.