tepkit.utils.mpl_tools.font_tools#

Attributes#

RECOMMENDED_SERIF_FONTS

RECOMMENDED_SANS_FONTS

RECOMMENDED_MONO_FONTS

RECOMMENDED_SERIF_FONTS_HANS

RECOMMENDED_SANS_FONTS_HANS

STYLE_TO_RECOMMENDED_FONTS

result

Functions#

is_font_avalible(→ bool)

get_avalible_font_by_names(→ str)

Return the first available font name from a list of font names.

get_recommended_font(→ str)

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 is False.

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