Query Windows fonts by name
Project description
windows-fonts
Enumerate and discover fonts on Windows
Why this module exists
Most (all?) python modules that render text to an image (matplotlib, PIL/Pillow etc) need to take a filename on Windows, but happily take a font name on other platforms, which is a) annoying from a cross-platform standpoint, and b) requires a bit of "faff" for the user to discover the font file for a given font.
Synopsis
>>> from windows_fonts import FontCollection, Weight
>>> fonts = FontCollection()
>>> # Get the first variant (light/regular/bold etc) for a named family
>>> family = fonts['Arial']
>>> variant = family[0]
>>> variant
<FontVariant family=<FontFamily name="Arial">, style=Style.NORMAL weight=Weight.REGULAR>
>>> print(variant.filename, variant.weight, variant.style)
C:\WINDOWS\FONTS\ARIAL.TTF Weight.REGULAR Style.NORMAL
# Find the "closest" variant for a given family
>>> variant = family.get_best_variant(weight=Weight.BOLD) # Or `style=Style.ITALIC, or both
>>> variant
<FontVariant family=<FontFamily name="Arial">, style=Style.NORMAL weight=Weight.BOLD>
# Or to find all "matching" variants in priority order:
>>> for variant in family.get_matching_variants(weight=Weight.BOLD):
... variant
...
<FontVariant family=<FontFamily name="Arial">, style=Style.NORMAL weight=Weight.BOLD>
<FontVariant family=<FontFamily name="Arial">, style=Style.NORMAL weight=Weight.BLACK>
<FontVariant family=<FontFamily name="Arial">, style=Style.NORMAL weight=Weight.BOLD>
<FontVariant family=<FontFamily name="Arial">, style=Style.ITALIIC weight=Weight.BOLD>
<FontVariant family=<FontFamily name="Arial">, style=Style.ITALIIC weight=Weight.BOLD>
<FontVariant family=<FontFamily name="Arial">, style=Style.NORMAL weight=Weight.BOLD>
<FontVariant family=<FontFamily name="Arial">, style=Style.NORMAL weight=Weight.BOLD>
<FontVariant family=<FontFamily name="Arial">, style=Style.ITALIIC weight=Weight.BOLD>
<FontVariant family=<FontFamily name="Arial">, style=Style.ITALIIC weight=Weight.BOLD>
Requirements
Python >= 3.7 Windows Vista and up
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file windows_fonts-1.0.0a1.tar.gz
.
File metadata
- Download URL: windows_fonts-1.0.0a1.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ffd75933eb84c825c335736f306968121342a89722420eff93b6917092384ed |
|
MD5 | 5936169d4d6f97e4142ce381679b0522 |
|
BLAKE2b-256 | 74f6819c7c4f1a9c91ddf2efd274f9472f65bbc8ba9575559b4e6708c153947e |
File details
Details for the file windows_fonts-1.0.0a1-cp311-none-win_amd64.whl
.
File metadata
- Download URL: windows_fonts-1.0.0a1-cp311-none-win_amd64.whl
- Upload date:
- Size: 166.0 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa96f26d57fe169fb911c71c1d37d74d5ad8e3629be7f9a8c96fd19b988f4ddc |
|
MD5 | 3024f316983e7c16ab54c0019ad13620 |
|
BLAKE2b-256 | f60f3762ad5dbbdac86c6f3030a9a982fecc09a1e532607834fa9cbde7b3e61d |
File details
Details for the file windows_fonts-1.0.0a1-cp310-none-win_amd64.whl
.
File metadata
- Download URL: windows_fonts-1.0.0a1-cp310-none-win_amd64.whl
- Upload date:
- Size: 166.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa4e73b058f738aff9fe83bcc4e326486aaed10b1f30add9c6e0a77e6cab23c3 |
|
MD5 | a5bb63a6b62d9ea4b42c96e2dee52078 |
|
BLAKE2b-256 | 41e1e6cfd5e74d9c6cfa0feb859759a0f6028caf3b3b4d0f19336bc2884dc191 |
File details
Details for the file windows_fonts-1.0.0a1-cp39-none-win_amd64.whl
.
File metadata
- Download URL: windows_fonts-1.0.0a1-cp39-none-win_amd64.whl
- Upload date:
- Size: 166.3 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ef05d6f1ee3b24005580ed7e51bdbf37339b54f40b61cb7c9a70d0d64c1790d |
|
MD5 | 45862f48673edce0ce63cd01c16e51dc |
|
BLAKE2b-256 | 4518f784b19063fb4cbe09f7392273104856d16aca7f6477e8acce53b5c783c1 |
File details
Details for the file windows_fonts-1.0.0a1-cp38-none-win_amd64.whl
.
File metadata
- Download URL: windows_fonts-1.0.0a1-cp38-none-win_amd64.whl
- Upload date:
- Size: 166.5 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85aedc35ab29e2ed6d341b939c0c9bc6669efb2449b730da60a01a57eec8454a |
|
MD5 | ea13cc0e938057e04da94a444da94a6a |
|
BLAKE2b-256 | 334e5961e9bb41ab161abc756f68e8b3d49dd4ea8c3c564c4d016c6a573eec6c |
File details
Details for the file windows_fonts-1.0.0a1-cp37-none-win_amd64.whl
.
File metadata
- Download URL: windows_fonts-1.0.0a1-cp37-none-win_amd64.whl
- Upload date:
- Size: 166.5 kB
- Tags: CPython 3.7, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99aa3c681c345090c62262b2a7757e5e695fccd349ae2eb37d30a182ab6fb702 |
|
MD5 | 20d80a6c39c689c387410d13ab435b70 |
|
BLAKE2b-256 | 322ed405f1a7ad075064eb61f791e1cb69867650adf34ecb2c48cae8e19f5ee1 |