googlefonts / googlefonts/fontc

Glyphs FEA predicate tokens: glyph-metadata attributes and nested boolean expressions

Open
#2,052 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
193
Forks
21
Avg merge
1d 17h
Merged PRs (30d)
65

Description

Follow-up to #92. Phase 1 there scopes 1.0 to name-only predicates which need nothing beyond the GlyphMap fea-rs already has. This issue is the deferred remainder: predicates that query glyph metadata, and nested boolean expressions.

As far as I can tell, only two crater sources need this:

ZalandoSans (zalando/sans): category/subCategory:

```
$[category like 'Number']
$[subCategory like 'Space']
```

Borel (RosaWagner/Borel): the full NSPredicate subset plus nested/parenthesised boolean, e.g. one `@short` class meaning "every exporting glyph that is an uppercase Letter with a Unicode value whose name starts with AE/C/E/T/X":

```
@short = [$[category like "Letter" && case==upper && unicode != nil && (name beginswith "AE" OR name beginswith "C" OR name beginswith "E" OR name beginswith "T" OR name beginswith "X")]];
```

What this needs on top of phase 1:

- Threading glyph metadata (category, subCategory, case, unicode) through to wherever predicates are expanded. fea-rs currently only receives glyph names. `case` in particular isn't retained by glyphs-reader today (it's dropped in glyphdata.rs), so that needs adding to the reader first.
- The `like` operator (`fnmatch`-style) and the `nil` literal (for `unicode != nil`).
- A real boolean parser: mixing `&&`/`OR`, parenthesised grouping, and `NOT` with proper precedence (phase 1 only needs a flat single-operator chain).

These are two fairly independent chunks: ZalandoSans needs only the metadata threading + `like`; Borel additionally needs `case` (including the glyphs-reader change), `unicode`/`nil`, and the nested-boolean parser.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading follow-up issue #92 and tracing how fea-rs expands predicates from GlyphMap glyph names. Inspect glyphs-reader's glyphdata.rs, especially where case is dropped, then map the metadata path into predicate expansion. Done means supporting metadata threading and like for ZalandoSans, with case, unicode/nil, and nested boolean precedence for Borel.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.