mcfonts.filters
¶
A filter is a class used to control what characters and providers are included or not included when exporting.
Module Contents¶
Classes¶
A filter used in exporting; this controls which glyphs are exported and under which conditions. |
|
How to handle filtered characters or providers. |
-
class mcfonts.filters.Filter(filtered_characters=
None
, filtered_providers=None
, character_policy=Policy.EXCLUDE
, provider_policy=Policy.EXCLUDE
)¶ A filter used in exporting; this controls which glyphs are exported and under which conditions.
Can either act as either an excluding filter, or an inclusive filter.
Construct a filter.
- Parameters:¶
- filtered_characters : set[str] | str | None¶
An optional string or set of strings of the character to add to the filter.
- filtered_providers : set[type[mcfonts.providers.base.Provider]] | None¶
An optional list of the types of providers to add to the filter.
- character_policy : Policy¶
The policy to use with regards to the character filter. Can also be an integer.
- provider_policy : Policy¶
The policy to use with regards to the provider filter. Can also be an integer.
- check_character(character)¶
Determine how character should be handled.
If character is in filtered characters and character policy is EXCLUDE, or
- If character is not in filtered characters and character policy is INCLUDE:
Skip character
- check_provider(provider)¶
Determine how provider should be handled.
If provider is in filtered providers and provider policy is EXCLUDE, or
- If provider is not in filtered providers and provider policy is INCLUDE:
Skip provider
- Parameters:¶
- provider : type[mcfonts.providers.base.Provider]¶
The type of the provider to determine filtering for; this is not an instance.
- Returns:¶
A boolean; True to skip, False to include normally.
- Return type:¶
bool
- set_character_policy(new_char_policy)¶
Set the character policy for how to handle filtering characters.
- set_provider_policy(new_provider_policy)¶
Set the provider policy for how to handle filtering providers.
- class mcfonts.filters.Policy¶
Bases:
enum.IntEnum
How to handle filtered characters or providers.
Initialize self. See help(type(self)) for accurate signature.
-
EXCLUDE =
1
¶ Include none of the predicate matches.
-
INCLUDE =
0
¶ Include only the predicate matches.
-
EXCLUDE =