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 |
required |
italic
|
Optional[bool]
|
Whether to use the italic variant. Default is |
None
|
allowed_formats
|
List[str]
|
List of acceptable font file formats. Defaults to ["woff", "ttf", "otf"].
Note that for |
['woff', 'ttf', 'otf']
|
use_cache
|
bool
|
Whether or not to cache fonts (to make pyfonts faster). Default to |
True
|
danger_not_verify_ssl
|
bool
|
Whether or not to to skip SSL certificate on
|
False
|
Returns:
| Type | Description |
|---|---|
FontProperties
|
matplotlib.font_manager.FontProperties: A |
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: