googlefonts / gftools

Misc tools for working with the Google Fonts library
Apache License 2.0
243 stars 70 forks source link

[Builder] Instances from designspace are being ommited #1042

Open guidoferreyra opened 1 month ago

guidoferreyra commented 1 month ago

I’m using the builder with a .designspace file but the instances listed on the designspace are being ommited on the final vf font. When I build the same designspace with fontmake all instances are ok.

Any clue what can be causing this? Thanks in advance!

arrowtype commented 1 week ago

I’m experiencing what might be a similar issue (or maybe not).

For several months, I’ve been building fonts that have a designspace, and outputting to both static and variable fonts.

For static fonts, the basic config options work. For variable fonts, I usually want to add a renaming step. So, based on the 4 instances of this designspace, I would expect this to build 4 static OTFs, 4 static TTFs, and 1 variable TTF:

familyName: Family
buildStatic: true
buildOTF: true
buildTTF: true
buildVariable: false
buildWebfont: false
outputDir: fonts
sources:
  - sources/ufo/Family.designspace
recipe:
  fonts/variable/Family[opsz].ttf:
    - source: sources/ufo/Family.designspace
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildVariable
    - args: "fix-nonhinting $in $out"
      exe: "gftools"
      operation: exec
    - args: "../scripts/rename-fonts.py $in --suffix 'Variable' && cp $in $out"
      exe: "python3"
      operation: exec

The config has worked like this for a good few months, at least.

However, now, it seems that if I included the specific recipe for the variable font, it cancels out the buildStatic: true option, and only builds a single variable font. If I leave out the recipe, it does build the static fonts, but then, of course, it no longer builds the variable font.

Did the interaction of the recipe vs options above change recently? Was this intentional? I don’t see anything obvious in the Releases, but I may not know what to look for.

arrowtype commented 1 week ago

As a workaround, I set up a simple recipe:

familyName: Family
buildStatic: true
buildVariable: true
buildWebfont: false
outputDir: fonts
sources:
  - sources/ufo/Family.designspace

Then ran gftools builder --generate <path_to_config>/config.yaml. Then, I copied the output, and re-added the variable steps as needed.

This is definitely not ideal, and would be pretty terrible for a family with more than four styles. So, I really hope this isn’t the new default expectation... But, it seems to work for now.

familyName: Family
buildStatic: true
buildVariable: true
buildWebfont: false
outputDir: fonts
cleanUp: true
recipe:
  fonts/otf/Family-Display.otf:
    - source: sources/ufo/Family.designspace
    - glyphData: null
      instance_name: Display
      operation: instantiateUfo
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildOTF
    - args: ""
      operation: fix
  fonts/otf/Family-Heading.otf:
    - source: sources/ufo/Family.designspace
    - glyphData: null
      instance_name: Heading
      operation: instantiateUfo
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildOTF
    - args: ""
      operation: fix
  fonts/otf/Family-Small.otf:
    - source: sources/ufo/Family.designspace
    - glyphData: null
      instance_name: Small
      operation: instantiateUfo
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildOTF
    - args: ""
      operation: fix
  fonts/otf/Family-Subhead.otf:
    - source: sources/ufo/Family.designspace
    - glyphData: null
      instance_name: Subhead
      operation: instantiateUfo
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildOTF
    - args: ""
      operation: fix
  fonts/ttf/Family-Display.ttf:
    - source: sources/ufo/Family.designspace
    - glyphData: null
      instance_name: Display
      operation: instantiateUfo
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildTTF
    - args: "--fail-ok "
      operation: autohint
    - args: ""
      operation: fix
  fonts/ttf/Family-Heading.ttf:
    - source: sources/ufo/Family.designspace
    - glyphData: null
      instance_name: Heading
      operation: instantiateUfo
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildTTF
    - args: "--fail-ok "
      operation: autohint
    - args: ""
      operation: fix
  fonts/ttf/Family-Small.ttf:
    - source: sources/ufo/Family.designspace
    - glyphData: null
      instance_name: Small
      operation: instantiateUfo
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildTTF
    - args: "--fail-ok "
      operation: autohint
    - args: ""
      operation: fix
  fonts/ttf/Family-Subhead.ttf:
    - source: sources/ufo/Family.designspace
    - glyphData: null
      instance_name: Subhead
      operation: instantiateUfo
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildTTF
    - args: "--fail-ok "
      operation: autohint
    - args: ""
      operation: fix
  fonts/variable/Family[opsz].ttf:
    - source: sources/ufo/Family.designspace
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildVariable
    - args: "fix-nonhinting $in $out"
      exe: "gftools"
      operation: exec
    - args: "../scripts/rename-fonts.py $in --suffix 'Variable' && cp $in $out"
      exe: "python3"
      operation: exec
recipeProvider: googlefonts
sources:
  - sources/ufo/Family.designspace