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 format (officially the “OpenType feature file”).
API stability between minor versions is not guaranteed before version 2.
Users are expected to use the fontTools.feaLib.ast classes directly for functionalities that are not yet covered by the FeaComposer API.
The API is designed to be close to the FEA syntax for familiarity, but is tightened up to be more manageable for complicated projects. On the other hand, as an embedded domain-specific language (eDSL) it allows you to take full advantage of Python, especially static type checking.
Do you need this?
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 format.
- You want to compose OpenType Layout (OTL) rules in Python code independently from the FEA format. You don’t need static type checking.
- Try fontFeatures, which allows you to work on the syntax tree of OTL rules rather than the 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 how the FEA code is formatted.
- Try FeaPyFoFum, which provides a template language for embedding Python inside FEA code.
Getting started
Install from PyPI:
pip install tptq-feacomposer
Note the namespace dot in the “import package” name below has been normalized to a dash in the “distribution package” name above. See also Distribution package vs. import package.
Compose FEA code in Python:
from tptq.feacomposer import FeaComposer
c = FeaComposer(languageSystems={})
with c.Lookup(feature="liga"):
c.sub("f", "i", by="f_i")
print(c.asFeatureFile())
The printed FEA code:
feature liga {
lookup _1 {
lookupflag 0;
sub f i by f_i;
} _1;
} liga;
See test.py for more examples.
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.11.4.tar.gz.
File metadata
- Download URL: tptq_feacomposer-1.11.4.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3105f025883f51a9cc578f757438a2bdf9cfdb89883ef634a07141c5f51207f9
|
|
| MD5 |
5aafcf9f318adff4dfc80f6ec686b01b
|
|
| BLAKE2b-256 |
199eacc46b97ca7148311a50ef7f2140ad898eabfdedc6eb4f507c54e9e68845
|
Provenance
The following attestation bundles were made for tptq_feacomposer-1.11.4.tar.gz:
Publisher:
pypi.yml on typotheque/feacomposer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tptq_feacomposer-1.11.4.tar.gz -
Subject digest:
3105f025883f51a9cc578f757438a2bdf9cfdb89883ef634a07141c5f51207f9 - Sigstore transparency entry: 582940451
- Sigstore integration time:
-
Permalink:
typotheque/feacomposer@7d98fb577218741cbda2b7b46bae045097bcb25b -
Branch / Tag:
refs/tags/v1.11.4 - Owner: https://github.com/typotheque
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@7d98fb577218741cbda2b7b46bae045097bcb25b -
Trigger Event:
release
-
Statement type:
File details
Details for the file tptq_feacomposer-1.11.4-py3-none-any.whl.
File metadata
- Download URL: tptq_feacomposer-1.11.4-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10ada925ab756f1cf71a910c7e89dcfb0b914f6e0eec0eedc219b7c7112bbc2b
|
|
| MD5 |
c392dd793569702e3a1fc073cc2197bf
|
|
| BLAKE2b-256 |
a870e79af7449db050d9fd0149d834df01286c38746f87667629f758974f7cc3
|
Provenance
The following attestation bundles were made for tptq_feacomposer-1.11.4-py3-none-any.whl:
Publisher:
pypi.yml on typotheque/feacomposer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tptq_feacomposer-1.11.4-py3-none-any.whl -
Subject digest:
10ada925ab756f1cf71a910c7e89dcfb0b914f6e0eec0eedc219b7c7112bbc2b - Sigstore transparency entry: 582940465
- Sigstore integration time:
-
Permalink:
typotheque/feacomposer@7d98fb577218741cbda2b7b46bae045097bcb25b -
Branch / Tag:
refs/tags/v1.11.4 - Owner: https://github.com/typotheque
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@7d98fb577218741cbda2b7b46bae045097bcb25b -
Trigger Event:
release
-
Statement type: