A feaLib wrapper for composing FEA code in Python
Project description
FeaComposer
FeaComposer is a wrapper around fontTools.feaLib.ast for programmatically composing code in the FEA syntaxt (formally known as the “OpenType feature file”). It’s an embedded domain-specific language (eDSL) in Python, developed with static type checking in mind.
The API is designed to be close to the FEA syntax, but is tightened up to be more manageable for complicated projects. Users are expected to use the fontTools.feaLib.ast classes directly for functionalities not yet covered by the FeaComposer API.
For the following use cases, you will not benefit from this package:
- You just want to write FEA code directly.
- Read The (Unofficial) OpenType Cookbook if you’re a beginner, and the OpenType Feature File Specification if you need to learn more about the FEA syntax.
- You want to compose OpenType Layout (OTL) rules in Python code independently from the FEA syntax. You don’t need static type checking.
- Try fontFeatures, which allows you to work on the syntax tree of OTL rules rather than the syntax tree of FEA code. It still allows you to export FEA code if you want.
- You want some Python logic in FEA code. You don’t need the usual code editor experience for Python, or you care about the FEA code’s exact format.
- Try FeaPyFoFum, which provides a template language for embedding Python inside FEA code.
Basic usage
from tptq.feacomposer import FeaComposer
c = FeaComposer()
with c.Lookup(feature="liga"):
c.sub(["f", "i"], "fi")
print(c.code())
The printed FEA code:
languagesystem DFLT dflt;
feature liga {
lookup _1 {
lookupflag 0;
sub f i by fi;
} _1;
} liga;
See test.py for more advanced usage.
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 tptq_feacomposer-1.1.0.tar.gz.
File metadata
- Download URL: tptq_feacomposer-1.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.0 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4aa6320dca73ded38b99746ef69e6fae3c95fda97d38284de9f9640c2a986d84
|
|
| MD5 |
812b1b2c13c716976de4bc471efc32f8
|
|
| BLAKE2b-256 |
f0e346af99d0741b72ab5dcee308148fc29cc4a6dc75cd6e9a0e65e2f285817c
|
File details
Details for the file tptq_feacomposer-1.1.0-py3-none-any.whl.
File metadata
- Download URL: tptq_feacomposer-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.0 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e270100e3befe1c2f2021699f419a24718215a9335e0413b89ef38c4ec2c96bc
|
|
| MD5 |
8368c93a698625ffc7d820e88266c78e
|
|
| BLAKE2b-256 |
b6eeed862c2297242285a4dc2dfc6f543168450157e5498a8be2e8f71730ded2
|