Converts ttf fonts to woff2 and removes glyphs that are not needed using the python library fonttools. You can 10x downsize ttf font files this way. The repo contains
- a bash script "font-optimizer.sh" to optimize fonts locally
- Basic code for a Python web app to run the optimizer with a GUI
- Dockerfile to simply deploy the code
Make sure you installed Python 3.12 on your system as well as the python libraries brotli 1.1.0 and fonttools 4.53.1
The script file needs execute permissions:
chmod +x font-optimizer.sh
It accepts one parameter, which is the path to the ttf file. Use it like this:
./font-optimizer.sh your-font.ttf
The result will be a your-font.woff2
file, with a limited character set.
To change, what characters will be included, update the unicodes param in the script.
You can follow the instructions from the Dockerfile
.
Make sure you have python 3.12 installed.
Install dependencies with
pip install -r requirements.txt
Start the app by running
python app.py
You can access the web interface on http://localhost:5000
Build the Docker image:
docker build . -t font-optimizer
Run the image:
docker run -p 5000:5000 font-optimizer
You can access the web interface on http://localhost:5000
You can use Sliplane to deploy the webapp.
- Fork the repo
- Login at Sliplane with your GitHub account and allow access to the forked repo
- Inside a project, click "Deploy Service" and choose a server to deploy to
- Choose repository as a deploy source
- Select the repository from the dropdown, keep the default settings and hit "Deploy"
Thanks to mrflix for sharing the bash script.
Checkout Sliplane for a simple way to deploy containerized apps.