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

mdi

Material Design Icons (Templarian)

7,448+

Filled + Outline

fa-solid

Font Awesome 6 Free Solid

2,000+

Filled

fa-regular

Font Awesome 6 Free Regular

160+

Outline

fa-brands

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')
MDI icon font rendering with icon_font

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 FontProperties object ready to pass directly to ax.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'
dartwork_mpl.icon.list_icon_fonts() list[str][source]

Return a list of available icon font identifiers.

Returns:

Sorted list of available identifiers (e.g., ['fa-brands', 'fa-regular', 'fa-solid', 'mdi']).

Return type:

list[str]