tepkit.utils.mpl_tools.font_tools#
Attributes#
|
|
|
|
|
|
|
|
|
|
|
|
|
Functions#
|
|
|
Return the first available font name from a list of font names. |
|
Get the first available font name by specify the font style. |
Module Contents#
- RECOMMENDED_SERIF_FONTS = ['Times New Roman', 'FreeSerif', 'DejaVu Serif']
- RECOMMENDED_SANS_FONTS = ['Helvetica', 'Arial', 'FreeSans', 'DejaVu Sans']
- RECOMMENDED_MONO_FONTS = ['Consolas', 'FreeMono', 'DejaVu Sans Mono']
- RECOMMENDED_SERIF_FONTS_HANS = ['Source Han Serif SC', 'Source Han Serif CN', 'SimSun']
- RECOMMENDED_SANS_FONTS_HANS = ['Source Han Sans SC', 'Source Han Sans CN', 'Microsoft YaHei']
- STYLE_TO_RECOMMENDED_FONTS
- is_font_avalible(font_name: str) bool #
- get_avalible_font_by_names(font_names: list[str], fallback: bool = False) str #
Return the first available font name from a list of font names.
- Parameters:
font_names – A list of possible font names.
fallback – Whether to return a fallback font (“DejaVu Sans”) if no available font in the list.
- Raises:
ValueError – If no available font in the list and
fallback
isFalse
.
- get_recommended_font(style: str) str #
Get the first available font name by specify the font style.
- Parameters:
style – One of the “Serif”, “Sans”, “Mono”, “Serif-Hans”, or “Sans-Hans”.
- result