Skip to content

gftools-gen-stat: allow a builder config file as STAT source - #1209

Open
RickyDaMa wants to merge 3 commits into
googlefonts:mainfrom
daltonmaag:gen-stat-builder-config
Open

gftools-gen-stat: allow a builder config file as STAT source#1209
RickyDaMa wants to merge 3 commits into
googlefonts:mainfrom
daltonmaag:gen-stat-builder-config

Conversation

@RickyDaMa

Copy link
Copy Markdown
Contributor

As I discovered the other day, if you aren't using the default Google Fonts recipe provider, your in-line STAT definition within your config.yaml isn't respected by the buildStat operation; it'll always auto-generate.

How the in-line STAT works with the Google Fonts recipe provider is a bit hacky and not simple to replicate without a full-blown custom recipe provider. So this PR takes a path with less resistance: by having gftools-gen-stat check for a "stat" key in the source YAML, and if found it uses its value instead of the full document. So now the following works:

# This is my sources/config.yaml
recipe:
  ../fonts/variable/MyFont[wght].ttf:
    - source: MyFont.glyphspackage
    - operation: buildVariable
    - operation: fix
    # Must be done as a post-processing step if stat is defined per-font,
    # because otherwise the file names won't match
    - postprocess: buildStat
      args: --src config.yaml  # 👈 specifying itself as the STAT source

stat:
  - name: Weight
    tag: wght
    values:
      - flags: 0
        name: Hairline
        value: 1.0
      # you know how this story goes...

Could I have just put the STAT definition in a separate file? Yes, and by all means reject this PR on that basis. But to me needing a separate stat.yaml doesn't feel very intuitive when you're transitioning from the default recipe builder.

I could look into having buildStat support a $src key if that's preferred over raw args. It's just more work then to integrate this with the existing Google Fonts recipe provider (which requires zero modifications with this PR as-is).


I also snuck in two unrelated changes: allowing STAT flags to be hex ints (I can remove this change if you want), and I also removed a debug print lying around in gftools-gen-stat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant