This tool allows you to get the font filename on your system. It will collect TrueType (.ttf), OpenType (.otf), TrueType Collection (.ttc) and OpenType Collection (.otc) font format.
It uses some APIs to find the font filename:
- Windows: DirectWrite API
- macOS: Core Text API
- Linux: Fontconfig API
- Android: NDK Font API
pip install FindSystemFontsFilename
from find_system_fonts_filename import get_system_fonts_filename, FindSystemFontsFilenameException
try:
fonts_filename = get_system_fonts_filename()
except FindSystemFontsFilenameException:
# Deal with the exception
pass
from find_system_fonts_filename import AndroidLibraryNotFound, get_system_fonts_filename, FontConfigNotFound, OSNotSupported
try:
fonts_filename = get_system_fonts_filename()
except (AndroidLibraryNotFound, FontConfigNotFound, OSNotSupported):
# Deal with the exception
# OSNotSupported can only happen in Windows, macOS and Android
# - Windows Vista SP2 and more are supported
# - macOS 10.6 and more are supported
# - Android SDK/API 29 and more are supported
# FontConfigNotFound can only happen on Linux when Fontconfig could't be found.
# AndroidLibraryNotFound can only happen on Android when the android library could't be found.
pass