Some small work with fonts.
Project description
fontra
| |
Some small work with fonts.
Features
- Font query via display name
- Custom font directories
Installation
Via pip:
pip install fontra
Usage
- Common font query
>>> import fontra
>>> fontra.all_fonts()
['Noto Sans Lisu', 'Noto Serif Tamil SemiCondensed', 'Noto Serif Georgian', 'Noto Sans Armenian', ...]
>>> fontra.get_font_styles("Arial")
['Regular', 'Italic', 'Bold', 'Bold Italic', 'Black']
>>> fontra.get_font("Arial", "Italic")
FontRef(path=PosixPath('/usr/share/fonts/TTF/ariali.ttf'), bank=0)
>>> fontra.unlocalized_name("更紗ゴシック UI J")
'Sarasa UI J'
>>> fontra.get_font("更纱黑体 SC", "SemiBold Italic")
FontRef(path=PosixPath('/usr/share/fonts/sarasa-gothic/Sarasa-SemiBoldItalic.ttc'), bank=1)
- Custom font directories
>>> fontra.FONTDIR_CUSTOM.append("./data/fonts")
>>> fontra.update_custom_fontfiles_index()
>>> fontra.update_fontrefs_index()
>>> fontra.all_fonts()
[...]
License
This project is under MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fontra-0.2.2.tar.gz
(4.6 kB
view hashes)
Built Distribution
fontra-0.2.2-py3-none-any.whl
(4.9 kB
view hashes)