Skip to content

Commit a5fa73a

Browse files
committed
Deprecate the TTFPATH & AFMPATH environment variables.
These undocumented environment variables allow one to selectively add paths to the font cache... but only if the font cache doesn't exist yet (they don't force cache regen). The font-cache regen API (_rebuild()) is also private (even though one can trigger it "publically" e.g. by calling `findfont` with a nonexisting font...). Instead, we now expose `addfont()` which is a documented API for registering fonts with the font manager.
1 parent bf74a40 commit a5fa73a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

doc/api/next_api_changes/deprecations.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,9 @@ Revert deprecation \*min, \*max keyword arguments to ``set_x/y/zlim_3d()``
7373
These keyword arguments were deprecated in 3.0, alongside with the respective
7474
parameters in ``set_xlim()`` / ``set_ylim()``. The deprecations of the 2D
7575
versions were already reverted in in 3.1.
76+
77+
The ``TTFPATH`` and ``AFMPATH`` environment variables
78+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
79+
Support for the (undocumented) ``TTFPATH`` and ``AFMPATH`` environment
80+
variables is deprecated. Additional fonts may be registered using
81+
``matplotlib.font_manager.fontManager.addfont()``.

lib/matplotlib/font_manager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,9 @@ def __init__(self, size=None, weight='normal'):
974974
paths.extend(ttfpath.split(':'))
975975
else:
976976
paths.append(ttfpath)
977+
cbook.warn_deprecated(
978+
"3.3", name=pathname, obj_type="environment variable",
979+
alternative="FontManager.addfont()")
977980
_log.debug('font search path %s', str(paths))
978981
# Load TrueType fonts and create font dictionary.
979982

0 commit comments

Comments
 (0)