googlefonts / googlefonts/fontc

[fea-rs] Support inline alternate substitution in contextual rules

Open
#1,925 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
193
Forks
21
Avg merge
1d 20h
Merged PRs (30d)
60

Description

fea-rs currently rejects inline alternate substitution rules in contextual (chained) context:

```fea
feature calt {
sub a' comma from [A a.alt1 a.alt2];
sub b' comma from [B b.alt];
} calt;

error: alternate substition rules cannot be specified inline
|
6 | sub a' comma from [A a.alt1 a.alt2];
| ^^^^
```

Although exotic, this is valid OpenType Feature File syntax. fonttools has supported compiling this since 2016 (fonttools/fonttools@db49f20d6, PR fonttools/fonttools#445). Just today, I added an optimization to reuse the same nested AlternateSubst lookup when consecutive chained alternate rules share the same context (fonttools/fonttools@0903764f8, PR https://github.com/fonttools/fonttools/pull/4061).

In order to match feaLib, fea-rs should:
1. Parse and compile `sub ' from ;` by creating a nested AlternateSubst lookup
2. Reuse the same nested lookup when consecutive rules share the same context

fonttools has a test for this: fontTools/Tests/feaLib/data/contextual_merge_alternate.{fea,ttx}.

Discovered while working on #1922 (contextual rule merging).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.