Skip to content

this Python script provides an interactive way to optimize fonts using the `pyftsubset` tool from the `fonttools` library. It allows users to customize various aspects of font subsetting, including which characters to keep, layout features to retain, and the output font format.

Notifications You must be signed in to change notification settings

OlinykFS/font-Optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Font Optimization Tool

This Python-based GUI tool allows users to optimize font files by subsetting specific glyphs, retaining layout features, and outputting them in various formats such as woff2. The tool uses fontTools and pyftsubset to handle font subsetting and provides an intuitive interface built with tkinter.

Features

  • Subset fonts: Remove unused glyphs from font files to reduce file size.
  • Retain layout features: Customize which OpenType features (like cv11, cv02, etc.) should be preserved.
  • Multiple input formats: Supports .ttf, .otf, .woff, and .woff2 font formats.
  • Multiple output formats: Output optimized fonts in different formats, including woff2.

Requirements

Before running the tool, make sure you have the following dependencies installed:

  1. Python 3.10+
  2. Required Python packages:
    • fonttools
    • ttkthemes
    • pyinstaller (for converting to .exe)
    • brotli (for WOFF2 font support)

Install the required packages using pip:

pip install fonttools ttkthemes brotli

Ensure pyftsubset is installed and accessible in your system's PATH:

pip install fonttools[subset]

Usage

Running the Application

You can run the tool directly using Python:

python main.py

Converting to an Executable (.exe)

To distribute the application as a standalone executable, use PyInstaller:

  1. Install PyInstaller:

    pip install pyinstaller
  2. Build the executable:

    pyinstaller --onefile --windowed main.py

This will create an .exe file inside the dist/ folder that can be run on any Windows machine.

Interface Overview

  • Source Font: Select the source font file (.ttf, .otf, .woff, or .woff2).
  • Output Directory: Choose where the optimized font will be saved.
  • Optimized Font Name: Enter a name for the new, optimized font (without extension).
  • Characters to Keep: Enter the glyphs (characters) you want to retain.
  • Layout Features: Specify which OpenType features should be retained in the output font.
  • Font Format: Select the output format (default is woff2).

License

This project is licensed under the MIT License.

Contributions

Contributions are welcome! Please fork the repository and submit a pull request.

About

this Python script provides an interactive way to optimize fonts using the `pyftsubset` tool from the `fonttools` library. It allows users to customize various aspects of font subsetting, including which characters to keep, layout features to retain, and the output font format.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages