Skip to main content

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.
  • 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={"latn": {"dflt"}})

with c.Lookup(feature="liga"):
    c.sub("f", "i", by="f_i")

print(c.asFeatureFile())

The printed FEA code:

languagesystem latn dflt;
feature liga {
    script latn;
    language dflt;
    lookup _1 {
        lookupflag 0;
        sub f i by f_i;
    } _1;

} liga;

To learn more, see examples.py and its output, examples.fea.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tptq_feacomposer-1.11.7.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tptq_feacomposer-1.11.7-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file tptq_feacomposer-1.11.7.tar.gz.

File metadata

  • Download URL: tptq_feacomposer-1.11.7.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tptq_feacomposer-1.11.7.tar.gz
Algorithm Hash digest
SHA256 aac2c4ad781fba86b1c95beb38063ba88c8c915b2a3f6b9ab85ebbbdd79426cd
MD5 ca86b15e2f5db8853389f29fbb0d92d1
BLAKE2b-256 bdf62880b670d62a3598c0dfab1788342870111650ccf53a69ce366245ec1dd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tptq_feacomposer-1.11.7.tar.gz:

Publisher: pypi.yml on typotheque/feacomposer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tptq_feacomposer-1.11.7-py3-none-any.whl.

File metadata

File hashes

Hashes for tptq_feacomposer-1.11.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d54d91fe780516d465b968e5d1bac2abd0ee3b5dcba07c2afe84afc8d9a93c35
MD5 e003135c380de1226af87d0b7df03afb
BLAKE2b-256 d9cc42f6a3cc225959607b611518289c16d78d0879ef61a7bff6c96cfad0e5b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for tptq_feacomposer-1.11.7-py3-none-any.whl:

Publisher: pypi.yml on typotheque/feacomposer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page