FontConfigSubstitutionRule class

FontConfigSubstitutionRule class

Font config substitution rule. To learn more, visit the Working with Fonts documentation article.

Remarks

This rule uses fontconfig utility on Linux (and other Unix-like) platforms to get the substitution if the original font is not available.

If fontconfig utility is not available then this rule will be ignored.

Inheritance: FontConfigSubstitutionRuleFontSubstitutionRule

Properties

NameDescription
enabledSpecifies whether the rule is enabled or not.

Methods

NameDescription
is_font_config_available()Check if fontconfig utility is available or not.
reset_cache()Resets the cache of fontconfig calling results.

Examples

Shows operating system-dependent font config substitution.

font_settings = aw.fonts.FontSettings()
font_config_substitution = font_settings.substitution_settings.font_config_substitution
# The FontConfigSubstitutionRule object works differently on Windows/non-Windows platforms.
# On Windows, it is unavailable.
# On Linux/Mac, we will have access to it, and will be able to perform operations.
is_windows = os.name == 'nt'
is_linux_or_mac = not is_windows
if is_windows:
    assert not font_config_substitution.enabled
    assert not font_config_substitution.is_font_config_available()
if is_linux_or_mac:
    assert font_config_substitution.enabled
    assert font_config_substitution.is_font_config_available()
font_config_substitution.reset_cache()

See Also