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 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.
  • 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


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.2.0.tar.gz (5.4 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.2.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tptq_feacomposer-1.2.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for tptq_feacomposer-1.2.0.tar.gz
Algorithm Hash digest
SHA256 3aa64cd05400a1b582b08653f1da8fc58341653f7a110c12de12a94dc9c2f452
MD5 2853a8639c90127dfac2681ca8a19bb2
BLAKE2b-256 51463b074e9ef1502985302384f1dc5a1343fedb0bd2bbe0103c2cd80fcc0c52

See more details on using hashes here.

Provenance

The following attestation bundles were made for tptq_feacomposer-1.2.0.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.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tptq_feacomposer-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcc1f4cec70cfd841643f50b2cf522d1974a476ff8ffd9f47f032bae71aece76
MD5 edfc210a5da67811bc56cd33bd306334
BLAKE2b-256 9649aa1c730c96574b55588e8e562e9ead81f92484538e75d693a3bc727e6f3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for tptq_feacomposer-1.2.0-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