Icon Font System¶
dartwork-mpl bundles icon fonts from Material Design Icons (MDI) and
Font Awesome 6 (FA6) in asset/icon/. They are auto-registered with
matplotlib on import, so you can render icons directly with ax.text().
Bundled Icon Fonts¶
Identifier |
Font |
Icons |
Style |
|---|---|---|---|
|
Material Design Icons (Templarian) |
7,448+ |
Filled + Outline |
|
Font Awesome 6 Free Solid |
2,000+ |
Filled |
|
Font Awesome 6 Free Regular |
160+ |
Outline |
|
Font Awesome 6 Brands |
460+ |
Brand logos |
Example¶
import dartwork_mpl as dm
# Load icon font
mdi = dm.icon_font('mdi')
fa = dm.icon_font('fa-solid')
fig, ax = plt.subplots()
# Render MDI thermometer icon
ax.text(0.5, 0.5, "\U000F050F",
fontproperties=mdi, fontsize=24,
ha='center', va='center', color='tw.teal500')
# Get font file path directly
path = dm.icon_font_path('mdi')
API¶
Icon font utilities for Matplotlib figures.
This module enables convenient loading of external icon fonts such as Material Design Icons and Font Awesome 6, rendering them as Unicode glyphs directly in Matplotlib.
Examples
>>> import dartwork_mpl as dm
>>> mdi = dm.icon_font('mdi')
>>> ax.text(0.5, 0.5, "", # thermometer icon
... fontproperties=mdi, fontsize=20)
- dartwork_mpl.icon.ensure_loaded() None[source]¶
Ensure icon fonts are loaded and registered if not already done.
- dartwork_mpl.icon.icon_font(name: str = 'mdi') FontProperties[source]¶
Create a
FontPropertiesobject ready to pass directly toax.text()and similar text functions.- Parameters:
name (str, optional) – Identifier of the icon font to load. Supported values:
'mdi','fa-solid','fa-regular','fa-brands'. Default is'mdi'.- Returns:
A configured Matplotlib FontProperties instance for the font.
- Return type:
FontProperties
Examples
>>> import dartwork_mpl as dm >>> mdi = dm.icon_font('mdi') >>> # Render an icon glyph at the center >>> ax.text(0.5, 0.5, "", ... fontproperties=mdi, fontsize=20, ... ha='center', va='center')
- dartwork_mpl.icon.icon_font_path(name: str = 'mdi') Path[source]¶
Return the absolute path to a bundled icon font file.
- Parameters:
name (str, optional) – Identifier of the icon font to access. Supported values:
'mdi','fa-solid','fa-regular','fa-brands'. Default is'mdi'.- Returns:
Absolute path to the font file (.ttf or .otf).
- Return type:
Path
- Raises:
ValueError – If name is not a registered font identifier.
FileNotFoundError – If the font file does not exist on disk.
Examples
>>> import dartwork_mpl as dm >>> path = dm.icon_font_path('mdi') >>> path.name 'materialdesignicons-webfont.ttf'