Metadata-Version: 2.1
Name: windows-fonts
Version: 1.0.0a1
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Text Processing :: Fonts
Requires-Dist: pytest >= 7; extra == 'tests'
Requires-Dist: black; extra == 'tests'
Requires-Dist: coverage; extra == 'tests'
Provides-Extra: tests
License-File: LICENSE
Summary: Query Windows fonts by name
Author-email: Ash Berlin-Taylor <ash_github@firemirror.com>
Requires-Python: >=3.7
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Issues, https://github.com/ashb/windows-fonts/issues
Project-URL: Homepage, https://github.com/ashb/windows-fonts

# 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

```python console
>>> 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

