FontMgr

class FontMgr

Font manager that knows system fonts.

Example:

fontmgr = skia.FontMgr()
print(list(fontmgr))
familyName = fontmgr[0]

typeface = fontmgr.matchFamilyStyle(familyName, skia.FontStyle.Normal())
assert typeface is not None

Methods

New_Custom_Empty

Overloaded function.

OneFontMgr

New_Custom_Empty(*args, **kwargs) Overloaded function.

RefDefault

Return the default fontmgr.

__init__

countFamilies

createStyleSet

getFamilyName

legacyMakeTypeface

makeFromData

Create a typeface for the specified data and TTC index (pass 0 for none) or NULL if the data is not recognized.

makeFromFile

Create a typeface for the specified fileName and TTC index (pass 0 for none) or NULL if the file is not found, or its contents are not recognized.

matchFamily

Never returns NULL; will return an empty set if the name is not found.

matchFamilyStyle

Find the closest matching typeface to the specified familyName and style and return a ref to it.

matchFamilyStyleCharacter

Use the system fallback to find a typeface for the given character.

ref

Increment the reference count.

unique

May return true if the caller is the only owner.

unref

Decrement the reference count.

Methods

static FontMgr.New_Custom_Empty(*args, **kwargs)

Overloaded function.

  1. New_Custom_Empty() -> skia.FontMgr

  2. New_Custom_Empty(filename: str) -> skia.FontMgr

  3. New_Custom_Empty(data: skia.Data) -> skia.FontMgr

FontMgr.OneFontMgr()

New_Custom_Empty(*args, **kwargs) Overloaded function.

  1. New_Custom_Empty() -> skia.FontMgr

  2. New_Custom_Empty(filename: str) -> skia.FontMgr

  3. New_Custom_Empty(data: skia.Data) -> skia.FontMgr

static FontMgr.RefDefault() skia.FontMgr

Return the default fontmgr.

FontMgr.__init__(self: skia.FontMgr) None
FontMgr.countFamilies(self: skia.FontMgr) int
FontMgr.createStyleSet(self: skia.FontMgr, index: int) skia.FontStyleSet
FontMgr.getFamilyName(self: skia.FontMgr, index: int) str
FontMgr.legacyMakeTypeface(self: skia.FontMgr, familyName: str, style: skia.FontStyle) skia.Typeface
FontMgr.makeFromData(self: skia.FontMgr, data: skia.Data, ttcIndex: int = 0) skia.Typeface

Create a typeface for the specified data and TTC index (pass 0 for none) or NULL if the data is not recognized.

FontMgr.makeFromFile(self: skia.FontMgr, path: str, ttcIndex: int = 0) skia.Typeface

Create a typeface for the specified fileName and TTC index (pass 0 for none) or NULL if the file is not found, or its contents are not recognized.

FontMgr.matchFamily(self: skia.FontMgr, familyName: str) skia.FontStyleSet

Never returns NULL; will return an empty set if the name is not found.

Passing nullptr as the parameter will return the default system family. Note that most systems don’t have a default system family, so passing nullptr will often result in the empty set.

It is possible that this will return a style set not accessible from createStyleSet(int) due to hidden or auto-activated fonts.

FontMgr.matchFamilyStyle(self: skia.FontMgr, familyName: object, style: skia.FontStyle) skia.Typeface

Find the closest matching typeface to the specified familyName and style and return a ref to it.

Will return nullptr if no ‘good’ match is found.

Passing nullptr as the parameter for familyName will return the default system font.

It is possible that this will return a style set not accessible from createStyleSet(int) or matchFamily(const char[]) due to hidden or auto-activated fonts.

FontMgr.matchFamilyStyleCharacter(self: skia.FontMgr, familyName: str, style: skia.FontStyle, bcp47: list[str], character: int) skia.Typeface

Use the system fallback to find a typeface for the given character.

Note that bcp47 is a combination of ISO 639, 15924, and 3166-1 codes, so it is fine to just pass a ISO 639 here.

Will return NULL if no family can be found for the character in the system fallback.

Passing nullptr as the parameter for familyName will return the default system font.

bcp47[0] is the least significant fallback, bcp47[bcp47Count-1] is the most significant. If no specified bcp47 codes match, any font with the requested character will be matched.

FontMgr.ref(self: skia.RefCntBase) None

Increment the reference count.

Must be balanced by a call to unref().

FontMgr.unique(self: skia.RefCntBase) bool

May return true if the caller is the only owner.

Ensures that all previous owner’s actions are complete.

FontMgr.unref(self: skia.RefCntBase) None

Decrement the reference count.

If the reference count is 1 before the decrement, then delete the object. Note that if this is the case, then the object needs to have been allocated via new, and not on the stack.