Python script to merge Adobe feature files into a single variable feature file
Reason this release was yanked:
Buggy and unusable
Project description
feamerge
Python scripts to merge all feature fea file in a designspace in common variable feature.fea file
This is an attempt to vibe code a solution to problem that fontc can not compile designspace with varying Opettype features.
Key Features
Designspace Integration
The script uses fontTools.designspaceLib.DesignSpaceDocument to read the designspace file and extract all UFO source references. It handles both absolute and relative paths correctly.
UFO Feature Reading
Using fontTools.ufoLib2.Font, the script opens each UFO and reads the features.fea content [1] [2]. This provides access to the complete feature definitions from each master.
Variable Font Syntax Generation
The script generates the variable font positioning syntax you requested:
-
Combines glyph classes from all masters
-
Creates positioning rules with coordinate:value pairs
-
Supports both regular and enum positioning statements
-
Formats output like:
pos A A (wdth=100,wght=400:10 wdth=100,wght=900:20)
Intelligent Merging
-
Glyph Classes: Merges and deduplicates glyph classes across masters
-
Kerning Values: Collects kerning values from each master and formats them with proper axis coordinates
-
Feature Preservation: Maintains other OpenType features beyond kerning
Usage
Installation Requirements
- Create a python virtual environmet and activate it
python3 -m venv venv
./venv/bin/activate
- Install the required fontTools components:
pip install fonttools[ufo]
Command Line
python3 combine_features.py MyFont.designspace variable_features.fea
Programmatic Usage
python
from combine_features import VariableFeatureCombiner
combiner = VariableFeatureCombiner("path/to/font.designspace")
combiner.save_combined_features("output/variable_features.fea")
This script provides a solid foundation for combining UFO feature files into variable font syntax. You may need to extend the parsing logic for more complex feature definitions or specific kerning patterns in your font sources. The feaLib module can also be used for more sophisticated feature file manipulation if needed.[3]
References
Preprocessing Python scripts
Two preprocesessing scripts are added to the repository for modifying feature.fea files before applying the features.
A script to break kerning groups:
-
Reads the feature.fea file from a UFO directory,
-
Detects the kerning groups definitions,
-
Expands groups in kerning pairs into individual glyph-to-glyph pairs,
-
Outputs a new feature.fea file with only individual kerning pairs, no groups.
This will facilitate feamerge merging by having a consistent non-grouped kerning state in the UFO feature file.
To use the sript run
python3 break_groups_in_fea.py path/to/YourFont.ufo
A script to break other positioning groups
-
Reads a UFO's feature.fea file,
-
Parses groups defined as @GroupName = [...];
-
Finds mark, abvm, blwm positioning statements containing group references,
-
Replaces group references with all individual glyph references,
-
Outputs a new feature.fea with expanded single-glyph anchor positioning rules (no group references) for these mark positioning tables.
It will write an expanded feature file (features_expanded_mark.fea) with all group references in mark positioning lines expanded to single glyphs, facilitating consistent merging or further processing.
To use the script run
python3 break_groups_in_mark_pos.py path/to/font.ufo
After the groups are broken into induvidual glyph entries they can be merged
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 feamerge-0.1.0.tar.gz.
File metadata
- Download URL: feamerge-0.1.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5031fac47d077f7e4f8e469f4d5bf11e3f97d97d85168fd8a4bfb6918f7adda6
|
|
| MD5 |
722f48a34fedf9d27fc902d7c11646a6
|
|
| BLAKE2b-256 |
a7e10b8a8de49a3109390aaa96e9df92b8b69a90ad6c540ee5fc2e7db3ab193d
|
File details
Details for the file feamerge-0.1.0-py3-none-any.whl.
File metadata
- Download URL: feamerge-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9bb7e9ac838eadd87744ba23eda3324e8a5615aee990142f0e8076f873b66f8
|
|
| MD5 |
f4007ddf766fedac419bfe9a4f67c370
|
|
| BLAKE2b-256 |
2f61ee0c50cf8603e7cde59b3a9512d0e71b8bd7d7ca681e4fc363f626a241d5
|