-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.4.0: added function to register the official font of the FAU CI (FA…
…USans) to matplotlib, assuming it was manually installed before.
- Loading branch information
Showing
4 changed files
with
129 additions
and
786 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "1.3.0" | ||
__version__ = "1.4.0" | ||
|
||
from fau_colors._utils import export_as_gpl | ||
from fau_colors.v2021 import cmaps, colors, colors_all, colors_dark, colors_light, register_cmaps, unregister_cmaps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from pathlib import Path | ||
|
||
from matplotlib import font_manager | ||
|
||
|
||
def register_fausans_font(): | ||
"""Register the FAU Sans font. | ||
This function tries to register the FAU Sans font by scanning the common font directories. | ||
If the font is not found, it will throw an error. | ||
Raises | ||
------ | ||
FileNotFoundError | ||
If the font file is not found. | ||
""" | ||
possible_paths = [ | ||
Path("/Library/Fonts/FAUSansOffice-Regular.ttf"), # macOS | ||
Path("/usr/share/fonts/truetype/fausans/FAUSansOffice-Regular.ttf"), # Linux | ||
Path("C:/Windows/Fonts/FAUSansOffice-Regular.ttf"), # Windows | ||
] | ||
for path in possible_paths: | ||
if path.exists(): | ||
font_manager.fontManager.addfont(path) | ||
return | ||
|
||
raise FileNotFoundError( | ||
"Could not find 'FAUSansOffice-Regular.ttf' on your system. Please install it manually and try again." | ||
) |
Oops, something went wrong.