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
windows_fonts-1.0.0a1.tar.gz
(16.1 kB
view hashes)
Built Distributions
Close
Hashes for windows_fonts-1.0.0a1-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa96f26d57fe169fb911c71c1d37d74d5ad8e3629be7f9a8c96fd19b988f4ddc |
|
MD5 | 3024f316983e7c16ab54c0019ad13620 |
|
BLAKE2b-256 | f60f3762ad5dbbdac86c6f3030a9a982fecc09a1e532607834fa9cbde7b3e61d |
Close
Hashes for windows_fonts-1.0.0a1-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa4e73b058f738aff9fe83bcc4e326486aaed10b1f30add9c6e0a77e6cab23c3 |
|
MD5 | a5bb63a6b62d9ea4b42c96e2dee52078 |
|
BLAKE2b-256 | 41e1e6cfd5e74d9c6cfa0feb859759a0f6028caf3b3b4d0f19336bc2884dc191 |
Close
Hashes for windows_fonts-1.0.0a1-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ef05d6f1ee3b24005580ed7e51bdbf37339b54f40b61cb7c9a70d0d64c1790d |
|
MD5 | 45862f48673edce0ce63cd01c16e51dc |
|
BLAKE2b-256 | 4518f784b19063fb4cbe09f7392273104856d16aca7f6477e8acce53b5c783c1 |
Close
Hashes for windows_fonts-1.0.0a1-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85aedc35ab29e2ed6d341b939c0c9bc6669efb2449b730da60a01a57eec8454a |
|
MD5 | ea13cc0e938057e04da94a444da94a6a |
|
BLAKE2b-256 | 334e5961e9bb41ab161abc756f68e8b3d49dd4ea8c3c564c4d016c6a573eec6c |
Close
Hashes for windows_fonts-1.0.0a1-cp37-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99aa3c681c345090c62262b2a7757e5e695fccd349ae2eb37d30a182ab6fb702 |
|
MD5 | 20d80a6c39c689c387410d13ab435b70 |
|
BLAKE2b-256 | 322ed405f1a7ad075064eb61f791e1cb69867650adf34ecb2c48cae8e19f5ee1 |