Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SkTypeface_fontconfig Class Reference
Inheritance diagram for SkTypeface_fontconfig:
SkTypeface_FreeType SkTypeface SkWeakRefCnt SkRefCnt SkRefCntBase

Public Member Functions

void onGetFamilyName (SkString *familyName) const override
 
void onGetFontDescriptor (SkFontDescriptor *desc, bool *serialize) const override
 
std::unique_ptr< SkStreamAssetonOpenStream (int *ttcIndex) const override
 
void onFilterRec (SkScalerContextRec *rec) const override
 
std::unique_ptr< SkAdvancedTypefaceMetricsonGetAdvancedMetrics () const override
 
sk_sp< SkTypefaceonMakeClone (const SkFontArguments &args) const override
 
std::unique_ptr< SkFontDataonMakeFontData () const override
 
 ~SkTypeface_fontconfig () override
 
- Public Member Functions inherited from SkTypeface_FreeType
std::unique_ptr< SkFontDatamakeFontData () const
 
FaceRecgetFaceRec () const
 
- 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 sk_sp< SkTypeface_fontconfigMake (SkAutoFcPattern pattern, SkString sysroot)
 
- Static Public Member Functions inherited from SkTypeface_FreeType
static int GetUnitsPerEm (FT_Face face)
 
static sk_sp< SkTypefaceMakeFromStream (std::unique_ptr< SkStreamAsset >, const SkFontArguments &)
 
- 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 &))
 

Public Attributes

SkAutoFcPattern fPattern
 
const SkString fSysroot
 

Additional Inherited Members

- Public Types inherited from SkTypeface
enum class  SerializeBehavior { kDoIncludeData , kDontIncludeData , kIncludeDataIfLocal }
 
using FactoryId = SkFourByteTag
 
- Static Public Attributes inherited from SkTypeface_FreeType
static constexpr SkTypeface::FactoryId FactoryId = SkSetFourByteTag('f','r','e','e')
 
- Protected Member Functions inherited from SkTypeface_FreeType
 SkTypeface_FreeType (const SkFontStyle &style, bool isFixedPitch)
 
 ~SkTypeface_FreeType () override
 
std::unique_ptr< SkFontDatacloneFontData (const SkFontArguments &, SkFontStyle *style) const
 
std::unique_ptr< SkScalerContextonCreateScalerContext (const SkScalerContextEffects &, const SkDescriptor *) const override
 
void onFilterRec (SkScalerContextRec *) const override
 
void getGlyphToUnicodeMap (SkUnichar *) const override
 
std::unique_ptr< SkAdvancedTypefaceMetricsonGetAdvancedMetrics () const override
 
void getPostScriptGlyphNames (SkString *dstArray) const override
 
bool onGetPostScriptName (SkString *) const override
 
int onGetUPEM () const override
 
bool onGetKerningPairAdjustments (const uint16_t glyphs[], int count, int32_t adjustments[]) const override
 
void onCharsToGlyphs (const SkUnichar uni[], int count, SkGlyphID glyphs[]) const override
 
int onCountGlyphs () const override
 
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, size_t offset, size_t length, void *data) const override
 
sk_sp< SkDataonCopyTableData (SkFontTableTag) 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 void onCharsToGlyphs (const SkUnichar *chars, int count, SkGlyphID glyphs[]) const =0
 
virtual bool onComputeBounds (SkRect *) const
 
virtual void * onGetCTFontRef () const
 
- Protected Member Functions inherited from SkWeakRefCnt
virtual void weak_dispose () const
 
- Static Protected Member Functions inherited from SkTypeface_FreeType
static void FontDataPaletteToDescriptorPalette (const SkFontData &, SkFontDescriptor *)
 

Detailed Description

Definition at line 413 of file SkFontMgr_fontconfig.cpp.

Constructor & Destructor Documentation

◆ ~SkTypeface_fontconfig()

SkTypeface_fontconfig::~SkTypeface_fontconfig ( )
inlineoverride

Definition at line 518 of file SkFontMgr_fontconfig.cpp.

518 {
519 // Hold the lock while unrefing the pattern.
520 FCLocker lock;
521 fPattern.reset();
522 }

Member Function Documentation

◆ Make()

static sk_sp< SkTypeface_fontconfig > SkTypeface_fontconfig::Make ( SkAutoFcPattern  pattern,
SkString  sysroot 
)
inlinestatic

Definition at line 415 of file SkFontMgr_fontconfig.cpp.

415 {
416 return sk_sp<SkTypeface_fontconfig>(new SkTypeface_fontconfig(std::move(pattern),
417 std::move(sysroot)));
418 }

◆ onFilterRec()

void SkTypeface_fontconfig::onFilterRec ( SkScalerContextRec rec) const
inlineoverridevirtual

Implements SkTypeface.

Definition at line 453 of file SkFontMgr_fontconfig.cpp.

453 {
454 // FontConfig provides 10-scale-bitmap-fonts.conf which applies an inverse "pixelsize"
455 // matrix. It is not known if this .conf is active or not, so it is not clear if
456 // "pixelsize" should be applied before this matrix. Since using a matrix with a bitmap
457 // font isn't a great idea, only apply the matrix to outline fonts.
458 const FcMatrix* fcMatrix = get_matrix(fPattern, FC_MATRIX);
459 bool fcOutline = get_bool(fPattern, FC_OUTLINE, true);
460 if (fcOutline && fcMatrix) {
461 // fPost2x2 is column-major, left handed (y down).
462 // FcMatrix is column-major, right handed (y up).
463 SkMatrix fm;
464 fm.setAll(fcMatrix->xx,-fcMatrix->xy, 0,
465 -fcMatrix->yx, fcMatrix->yy, 0,
466 0 , 0 , 1);
467
468 SkMatrix sm;
469 rec->getMatrixFrom2x2(&sm);
470
471 sm.preConcat(fm);
472 rec->fPost2x2[0][0] = sm.getScaleX();
473 rec->fPost2x2[0][1] = sm.getSkewX();
474 rec->fPost2x2[1][0] = sm.getSkewY();
475 rec->fPost2x2[1][1] = sm.getScaleY();
476 }
477 if (get_bool(fPattern, FC_EMBOLDEN)) {
479 }
480 this->INHERITED::onFilterRec(rec);
481 }
static const FcMatrix * get_matrix(FcPattern *pattern, const char object[])
static bool get_bool(FcPattern *pattern, const char object[], bool missing=false)
SkScalar getSkewY() const
Definition SkMatrix.h:430
SkMatrix & setAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar persp0, SkScalar persp1, SkScalar persp2)
Definition SkMatrix.h:562
SkScalar getSkewX() const
Definition SkMatrix.h:438
SkScalar getScaleX() const
Definition SkMatrix.h:415
SkMatrix & preConcat(const SkMatrix &other)
Definition SkMatrix.cpp:674
SkScalar getScaleY() const
Definition SkMatrix.h:422
void onFilterRec(SkScalerContextRec *) const override
void getMatrixFrom2x2(SkMatrix *) const
SkScalar fPost2x2[2][2]

◆ onGetAdvancedMetrics()

std::unique_ptr< SkAdvancedTypefaceMetrics > SkTypeface_fontconfig::onGetAdvancedMetrics ( ) const
inlineoverridevirtual

Implements SkTypeface.

Definition at line 483 of file SkFontMgr_fontconfig.cpp.

483 {
484 std::unique_ptr<SkAdvancedTypefaceMetrics> info =
486
487 // Simulated fonts shouldn't be considered to be of the type of their data.
488 if (get_matrix(fPattern, FC_MATRIX) || get_bool(fPattern, FC_EMBOLDEN)) {
490 }
491 return info;
492 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
std::unique_ptr< SkAdvancedTypefaceMetrics > onGetAdvancedMetrics() const override

◆ onGetFamilyName()

void SkTypeface_fontconfig::onGetFamilyName ( SkString familyName) const
inlineoverridevirtual

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 422 of file SkFontMgr_fontconfig.cpp.

422 {
423 *familyName = get_string(fPattern, FC_FAMILY);
424 }
static const char * get_string(FcPattern *pattern, const char object[], const char *missing="")

◆ onGetFontDescriptor()

void SkTypeface_fontconfig::onGetFontDescriptor ( SkFontDescriptor desc,
bool *  serialize 
) const
inlineoverridevirtual

Implements SkTypeface.

Definition at line 426 of file SkFontMgr_fontconfig.cpp.

426 {
427 // TODO: need to serialize FC_MATRIX and FC_EMBOLDEN
428 FCLocker lock;
429 desc->setFamilyName(get_string(fPattern, FC_FAMILY));
430 desc->setFullName(get_string(fPattern, FC_FULLNAME));
431 desc->setPostscriptName(get_string(fPattern, FC_POSTSCRIPT_NAME));
432 desc->setStyle(this->fontStyle());
434 *serialize = false;
435 }
#define FC_POSTSCRIPT_NAME
void setFactoryId(SkTypeface::FactoryId factoryId)
SkFontStyle fontStyle() const
Definition SkTypeface.h:55
void serialize(SkWStream *, SerializeBehavior=SerializeBehavior::kIncludeDataIfLocal) const
SkFourByteTag FactoryId
Definition SkTypeface.h:335

◆ onMakeClone()

sk_sp< SkTypeface > SkTypeface_fontconfig::onMakeClone ( const SkFontArguments args) const
inlineoverridevirtual

Implements SkTypeface.

Definition at line 494 of file SkFontMgr_fontconfig.cpp.

494 {
495 SkFontStyle style = this->fontStyle();
496 std::unique_ptr<SkFontData> data = this->cloneFontData(args, &style);
497 if (!data) {
498 return nullptr;
499 }
500
501 // TODO: need to clone FC_MATRIX and FC_EMBOLDEN
502 SkString familyName;
503 this->getFamilyName(&familyName);
504 return sk_make_sp<SkTypeface_FreeTypeStream>(
505 std::move(data), familyName, style, this->isFixedPitch());
506 }
std::unique_ptr< SkFontData > cloneFontData(const SkFontArguments &, SkFontStyle *style) const
void getFamilyName(SkString *name) const
bool isFixedPitch() const
Definition SkTypeface.h:68
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ onMakeFontData()

std::unique_ptr< SkFontData > SkTypeface_fontconfig::onMakeFontData ( ) const
inlineoverridevirtual

Implements SkTypeface_FreeType.

Definition at line 508 of file SkFontMgr_fontconfig.cpp.

508 {
509 int index;
510 std::unique_ptr<SkStreamAsset> stream(this->onOpenStream(&index));
511 if (!stream) {
512 return nullptr;
513 }
514 // TODO: FC_VARIABLE and FC_FONT_VARIATIONS
515 return std::make_unique<SkFontData>(std::move(stream), index, 0, nullptr, 0, nullptr, 0);
516 }
std::unique_ptr< SkStreamAsset > onOpenStream(int *ttcIndex) const override

◆ onOpenStream()

std::unique_ptr< SkStreamAsset > SkTypeface_fontconfig::onOpenStream ( int ttcIndex) const
inlineoverridevirtual

Implements SkTypeface.

Definition at line 437 of file SkFontMgr_fontconfig.cpp.

437 {
438 FCLocker lock;
439 *ttcIndex = get_int(fPattern, FC_INDEX, 0);
440 const char* filename = get_string(fPattern, FC_FILE);
441 // See FontAccessible for note on searching sysroot then non-sysroot path.
442 SkString resolvedFilename;
443 if (!fSysroot.isEmpty()) {
444 resolvedFilename = fSysroot;
445 resolvedFilename += filename;
446 if (sk_exists(resolvedFilename.c_str(), kRead_SkFILE_Flag)) {
447 filename = resolvedFilename.c_str();
448 }
449 }
450 return SkStream::MakeFromFile(filename);
451 }
static int get_int(FcPattern *pattern, const char object[], int missing)
bool sk_exists(const char *path, SkFILE_Flags=(SkFILE_Flags) 0)
@ kRead_SkFILE_Flag
Definition SkOSFile.h:20
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
Definition SkStream.cpp:922
bool isEmpty() const
Definition SkString.h:130
const char * c_str() const
Definition SkString.h:133

Member Data Documentation

◆ fPattern

SkAutoFcPattern SkTypeface_fontconfig::fPattern
mutable

Definition at line 419 of file SkFontMgr_fontconfig.cpp.

◆ fSysroot

const SkString SkTypeface_fontconfig::fSysroot

Definition at line 420 of file SkFontMgr_fontconfig.cpp.


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