Description
Starting with Windows 1809, it is now possible to install fonts in the user directory (search for "Font") without the requirement of having administration privileges. These fonts are currently not detected by matplotlib. The main problem is that fonts may be installed accidentally to the user folder and then it is not clear why matplotlib does not detect them (this was the case for me as I din't realize that I installed the font in the user directory).
For anyone facing this issue: a quick workaround is to install the font for all users, i.e. right click and then "Install for all users".
The user fonts are installed in the directory %userprofile%\AppData\Local\Microsoft\Windows\Fonts
and there are also registry keys in HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Fonts
. The nice thing is that these registry keys also contain (at least on my system) the absolute path to the font files. This is not the case for the system-wide font files.
The function findSystemFonts()
seems to be responsible to find all fonts on the system and as far as I can tell, it uses two approaches
- Collect all fonts which are installed on the system via the registry.
- Collect all fonts stored in the directory obtained via
win32FontDirectory()
. In most of the cases, this probably leads to the Windows font directory (C:\Windows\Fonts
).
Hence, my approach to fix this issue would also be in two steps:
- Iterate over the user font registry keys in
win32InstalledFonts()
. Since the absolute path is stored in the registry, no additional directory information is required here. Alternatively, a new functionwin32InstalledUserFonts()
may be more appropriate (any thoughts?). - Additionally, I would add the user font directory to the
fontpaths
list infindSystemFonts()
.
This should detect all user fonts.
If this strategy sounds reasonable to you, I can give it a try :-)
Matplotlib version
- Operating system: Windows x64 1809
- Matplotlib version: 3.0.2
- Python version: 3.6.7