fontra
|
|
Font indexing and querying support like fontconfig.
Features
- Font indexing and querying via display name
- Specifying custom font directories
- CLI for listing fonts
Installation
Via pip:
pip install fontra
For some advanced tools:
pip install fontra[tools]which currently enables you to:
- Extract a .ttc file to .ttf files
Usage
Command-line interface
fontra --help
--version
list
List available fonts.
--tree/[--table] | -t/[-T]
Whether to display a tree or a table.
--sort/[--no-sort] | -s/[-S]
Whether to output with sorted font names.
--localized/[--unlocalized] | -l/[-L]
Whether to show localized font names.
fontdirs
Show the font search directories.
show NAME...
Show the font information.
[--localized]/--unlocalized | -l/[-L]
Whether to lookup the localized index.
--fuzzy/[--exact] | -f/[-F]
Whether to fuzzy match.
--verbose/-v
Whether to show font path
unlocalize NAME
Convert a name into an unlocalized name.
unpack PATH
Unpack a TTC to TTF. (Requires fontra[tools] installed)
--output OUTPUT
Path to the output directory.
Font indexing and querying
>>> import fontra
>>> fontra.init_fontdb() # Initialize and search fonts
>>> 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.has_font_family("Helvetica")
False
>>> fontra.has_font_style("Comic Sans MS", "Light")
False
>>> fontra.get_unlocalized_name("更紗ゴシック UI J")
'Sarasa UI J'
>>> fontra.get_localized_names("LXGW WenKai TC")
['霞鶩文楷 TC', '霞鹜文楷 TC']
>>> fontra.get_font("更纱黑体 SC", "SemiBold Italic")
FontRef(path=PosixPath('/usr/share/fonts/sarasa-gothic/Sarasa-SemiBoldItalic.ttc'), bank=1)
Custom font directories
>>> from pathlib import Path
>>> fontra.FONTDIR_CUSTOM.append(Path("~/.fonts"))
>>> fontra.update_custom_fontfiles_index()
>>> fontra.update_fontrefs_index()
>>> fontra.all_fonts()
[...]
From environment variable
PYFONTRA_CUSTOM_FONTDIRS=~/.fonts fontra
License
This project is under MIT License.
Metadata
Release files for fontra 0.5.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fontra-0.5.2.tar.gz | 11.2 kB | Without provenance | Details for fontra-0.5.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fontra-0.5.2-py3-none-any.whl | Python 3 | none | any | Details for fontra-0.5.2-py3-none-any.whl |
Total release size: 22.8 kB
Release files / fontra-0.5.2.tar.gz
| Download URL | fontra-0.5.2.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd78c57ddfbc329ab5ae769eca7c230c542d8554f90be0e73c2ae22d4b050c64
|
|
BLAKE2b-256 checksum How to use checksums |
e8e610c7cdc25346ccc72ff7e3b81b6c7f29a41ecb8a8e3cb97089dfed1726d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / fontra-0.5.2-py3-none-any.whl
| Download URL | fontra-0.5.2-py3-none-any.whl |
|---|---|
| Size | 11.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff54a060b800abfc8348fa691695ef1c432886af97e08280094f41ba5ca60002
|
|
BLAKE2b-256 checksum How to use checksums |
b5664d0b9eb6ce82d479d36eb72b76db38a897ab2eb87ba8e118f9d241516025
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Security for fontra 0.5.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.