Automatically create an optimized subset font using fonttool's pyftsubset
Project description
autosubset – Automatically subset a font based on actual text
autosubset creates a subset font exactly for the set of characters that you
actually use.
Usage
Just pipe the text into autosubset and specify the font.
Assuming all your text is in the HTML files in the current directory:
html2text *.html | autosubset.py MyFont.woff2
autosubset analyzes the content, extracts the characters used and uses
pyftsubst from
fonttools to create a matching
subset.
After that, just add lines like the following to your web site:
- HTML: Preload the font for faster availability.
<link rel="preload" href="MyFont.subset.woff2" as="font" type="font/woff2">
- CSS: Define and use the font.
@font-face { font-family: "My Font"; src: local("Tenor Sans"), url("MyFont.subset.woff2") format("woff2"); font-display: fallback; } @body { font-family: "My Font", "System Fallback Font", sans; }
Whenever you change your text, make sure to rerun autosubst. This ensures
that the browser does not need to substitute characters from the fallback
fonts.
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 Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autosubset-0.2.2.post1.tar.gz.
File metadata
- Download URL: autosubset-0.2.2.post1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ac6b7b18136be87d8b5dac77e7b120489c1ca70f0180ab9ef4517280df60717
|
|
| MD5 |
71949179145de2266821bff4861c9fa8
|
|
| BLAKE2b-256 |
08c94ab8f571c7ed4d15bbea68cd81e7af77dad5ce304e3f57e243cd648652d4
|
File details
Details for the file autosubset-0.2.2.post1-py3-none-any.whl.
File metadata
- Download URL: autosubset-0.2.2.post1-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7e316523ca936bffd9b6f49a6c49b8d5af7114b3832b262f8b619da2dce9102
|
|
| MD5 |
7a1f5cd60e95dfc2be7071409949016d
|
|
| BLAKE2b-256 |
64382190f93671a0a0b3c8e419a701a7e49e084dfbc0b2870d13f855166d521c
|