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.1.0.tar.gz (5.3 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.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

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

Hashes for tptq_feacomposer-1.1.0.tar.gz
Algorithm Hash digest
SHA256 4aa6320dca73ded38b99746ef69e6fae3c95fda97d38284de9f9640c2a986d84
MD5 812b1b2c13c716976de4bc471efc32f8
BLAKE2b-256 f0e346af99d0741b72ab5dcee308148fc29cc4a6dc75cd6e9a0e65e2f285817c

See more details on using hashes here.

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

Hashes for tptq_feacomposer-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e270100e3befe1c2f2021699f419a24718215a9335e0413b89ef38c4ec2c96bc
MD5 8368c93a698625ffc7d820e88266c78e
BLAKE2b-256 b6eeed862c2297242285a4dc2dfc6f543168450157e5498a8be2e8f71730ded2

See more details on using hashes here.

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