Styling Context
Central configuration for fonts, colors, and styling options with proper bundled font management.
FontConfig
dataclass
Configuration for fonts used in plots.
Source code in pyretailscience/plots/styles/styling_context.py
StylingContext
Central styling context for fonts and styling options.
Source code in pyretailscience/plots/styles/styling_context.py
__init__()
Initialize the styling context with default fonts and cache.
Source code in pyretailscience/plots/styles/styling_context.py
get_font_properties(font_name)
Get matplotlib FontProperties with flexible font resolution.
This method resolves fonts in the following priority order: 1. Check cache for previously loaded font 2. Try to load from bundled fonts if font_name matches a built-in font 3. Try to load as a system font family name
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
font_name |
str
|
The name of the font to load. Can be: - A built-in font name (e.g., 'poppins_regular') - A system font family name (e.g., 'Arial', 'Times New Roman') |
required |
Returns:
| Type | Description |
|---|---|
FontProperties
|
fm.FontProperties: A matplotlib FontProperties object that can be used for text rendering. |