Skip to content

Load Bunny font


pyfonts.load_bunny_font(family, weight=None, italic=None, allowed_formats=['woff', 'ttf', 'otf'], use_cache=True, danger_not_verify_ssl=False)

Load a font from bunny Fonts with specified styling options and return a font property object that you can then use in your matplotlib charts.

The easiest way to find the font you want is to browse bunny font and then pass the font name to the family argument.

Parameters:

Name Type Description Default
family str

Font family name (e.g., "Open Sans", "Roboto", etc). weight: Desired font weight (e.g., 400, 700) or one of 'thin', 'extra-light', 'light', 'regular', 'medium', 'semi-bold', 'bold', 'extra-bold', 'black'. Default is None.

required
italic Optional[bool]

Whether to use the italic variant. Default is None.

None
allowed_formats List[str]

List of acceptable font file formats. Defaults to ["woff", "ttf", "otf"]. Note that for woff2 fonts to work, you must have brotli installed.

['woff', 'ttf', 'otf']
use_cache bool

Whether or not to cache fonts (to make pyfonts faster). Default to True.

True
danger_not_verify_ssl bool

Whether or not to to skip SSL certificate on ssl.SSLCertVerificationError. If True, it's a security risk (such as data breaches or man-in-the-middle attacks), but can be convenient in some cases, like local development when behind a firewall.

False

Returns:

Type Description
FontProperties

matplotlib.font_manager.FontProperties: A FontProperties object containing the loaded font.

Examples:

```python
from pyfonts import load_bunny_font

font = load_bunny_font("Roboto") # default Roboto font
font = load_bunny_font("Roboto", weight="bold") # bold font
font = load_bunny_font("Roboto", italic=True) # italic font
font = load_bunny_font("Roboto", weight="bold", italic=True) # italic and bold
```


Examples

Basic usage

# mkdocs: render
import matplotlib.pyplot as plt
from pyfonts import load_bunny_font

font = load_bunny_font("Alumni Sans") # default Alice font

fig, ax = plt.subplots()
ax.text(
   x=0.2,
   y=0.3,
   s="Hey there!",
   size=30,
   font=font
)

Custom font

# mkdocs: render
import matplotlib.pyplot as plt
from pyfonts import load_bunny_font

font = load_bunny_font("Alumni Sans", weight="bold", italic=True) # italic and bold

fig, ax = plt.subplots()
ax.text(
   x=0.2,
   y=0.3,
   s="Hey there!",
   size=30,
   font=font
)

Use multiple fonts

# mkdocs: render
import matplotlib.pyplot as plt
from pyfonts import load_bunny_font

font_bold = load_bunny_font("Alumni Sans", weight="bold")
font_italic = load_bunny_font("Alumni Sans", italic=True)

fig, ax = plt.subplots()

ax.text(
   x=0.2,
   y=0.3,
   s="Hey bold!",
   size=30,
   font=font_bold
)

ax.text(
   x=0.4,
   y=0.6,
   s="Hey italic!",
   size=30,
   font=font_italic
)

Fancy font

All fonts from Bunny font can be used:

# mkdocs: render
import matplotlib.pyplot as plt
from pyfonts import load_bunny_font

font = load_bunny_font("Barrio")

fig, ax = plt.subplots()
ax.text(
   x=0.1,
   y=0.3,
   s="What a weird font!",
   size=30,
   font=font
)