Skip to content

Commit 18a82c3

Browse files
committed
Add svg_usefonts themeable
closes #756
1 parent 72d5595 commit 18a82c3

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

doc/_quartodoc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ quartodoc:
478478
- strip_text_x
479479
- strip_text_y
480480
- subplots_adjust
481+
- svg_usefonts
481482
- text
482483
- title
483484

doc/changelog.qmd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ title: Changelog
1919
- Fixed images generated in quarto so that they have the dimensions
2020
(taking the dpi into account) that are specified in theme. ({{< issue 773 >}})
2121

22+
### New
23+
24+
- Added themeable [](:class:`~plotnine.themes.themeable.svg_usefonts`).
25+
({{< issue 756 >}})
26+
2227
### Enhancements
2328

2429
- Added _palmerpenguins_ dataset.

plotnine/themes/theme.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def __init__(
218218
strip_align_x=None,
219219
strip_align_y=None,
220220
strip_align=None,
221+
svg_usefonts=None,
221222
**kwargs,
222223
):
223224
self.themeables = Themeables()

plotnine/themes/themeable.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,6 +2384,33 @@ class strip_align(strip_align_x, strip_align_y):
23842384
"""
23852385

23862386

2387+
class svg_usefonts(themeable):
2388+
"""
2389+
How to renderer fonts for svg images
2390+
2391+
Parameters
2392+
----------
2393+
theme_element : bool
2394+
If `True`, assume fonts are installed on the machine where
2395+
the SVG will be viewed.
2396+
2397+
If `False`, embed characters as paths; this is supported by
2398+
most SVG renderers.
2399+
2400+
You should probably set this to `True` if you intend to edit
2401+
the svg file.
2402+
"""
2403+
2404+
@property
2405+
def rcParams(self) -> dict[str, Any]:
2406+
rcParams = super().rcParams
2407+
2408+
rcParams["svg.fonttype"] = (
2409+
"none" if self.properties.get("value") else "path"
2410+
)
2411+
return rcParams
2412+
2413+
23872414
# Deprecated
23882415

23892416

0 commit comments

Comments
 (0)