googlefonts / gftools

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

Builder "rename" operation doesn’t adjust VF instance postscript names. Should it? #965

Closed arrowtype closed 3 months ago

arrowtype commented 3 months ago

I’m running a gf builder config that adds the suffix "Variable" to variable fonts, so they can be installed concurrently with Static fonts of the same family, without conflict.

This works pretty well, but I’m getting a fontbakery fail, and I’m uncertain whether to worry about it.

Specifically, after the suffix renaming, com.adobe.fonts/check/varfont/valid_default_instance_nameids gives a FAIL result because the default instance of the family (Light Italic) has a postscript name that no longer matches the NameID 6 postscript name of the variable font.

I’m not sure this is an actual problem – my guess is, the postscript name of the instance would only be used if that instance were sliced into a static font, in which case I would imagine the non-suffixed postscript name might make sense. (Or, would NameID 25, the variable font postscript prefix, be used instead? Maybe it depends on the app doing the slicing?)

To be fair, the function this step ultimately seems to boil down to says that it is for renaming static fonts, and maybe suffixing a variable font is simply outside of the intended scope:

https://github.com/googlefonts/gftools/blob/cf6a61f98f732212227d2db65f4aaddaf4f2481a/Lib/gftools/fix.py#L351-L383

Then again, if I were really trying to rename the font completely, e.g. from "Stephen Sans" to "Steve Sans," it might be a bigger issue.

So, two questions:

  1. Is the non-renamed postscript names of the instances a problem, or not really?
  2. If, upon further testing, I determine it to be a problem, would a PR be considered here, or should I look to fix the renaming elsewhere in my build?

Context

Here’s my builder config, including the rename step:

familyName: Familyname
buildVariable: false
buildStatic: false
buildWebfont: false
autohintOTF: true
autohintTTF: true
outputDir: ./fonts
sources:
  - sources/ufo/FamilynameRoman.designspace
  - sources/ufo/FamilynameItalic.designspace
recipeProvider: googlefonts
recipe:
  fonts/variable/FamilynameRoman[wdth,wght].ttf:
    - source: sources/ufo/FamilynameRoman.designspace
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildVariable
    - args: "fix-gasp --autofix $in && cp $in.fix $out"
      exe: "gftools"
      operation: exec
    - operation: rename
      name: Familyname Variable
  fonts/variable/FamilynameItalic[wdth,wght].ttf:
    - source: sources/ufo/FamilynameItalic.designspace
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildVariable
    - args: "fix-gasp --autofix $in && cp $in.fix $out"
      exe: "gftools"
      operation: exec
    - operation: rename
      name: Familyname Variable
    - args: "--src stat.yaml"
      needs:
        - ./fonts/variable/FamilynameRoman[wdth,wght].ttf
      postprocess: buildStat
arrowtype commented 3 months ago

Ah, my mistake!

I just noticed in the build log that the gftools rename-font operation was being run with a --just-family arg. This arg limits the effects of renaming to only a few specific name IDs. If I instead run the renaming tool through an exec operation step in the recipe, the renaming happens, including for the instance postscript names.

In a single command-line command, it would be like this:

gftools rename-font "Familyname[wdth].ttf" "Familyname Variable" # do not include arg "--just-family"

In a builder config, it works like this:

familyName: Familyname
buildStatic: true
buildVariable: false
buildWebfont: false
autohintOTF: true
autohintTTF: true
interpolate: true
outputDir: ./fonts
sources:
  - sources/ufo/FamilynameRoman.designspace
  - sources/ufo/FamilynameItalic.designspace
recipeProvider: googlefonts
recipe:
  fonts/variable/FamilynameRoman[wdth].ttf:
    - source: sources/ufo/FamilynameRoman.designspace
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildVariable
    - args: "fix-nonhinting $in $out"
      exe: "gftools"
      operation: exec
    # doing the following instead of a "rename" operation also updates the instance postscript names
    - args: "rename-font $in 'Familyname Variable' && cp $in $out"
      exe: "gftools"
      operation: exec
  fonts/variable/FamilynameItalic[wdth].ttf:
    - source: sources/ufo/FamilynameItalic.designspace
    - args: --filter ...  --filter FlattenComponentsFilter --filter DecomposeTransformedComponentsFilter
      operation: buildVariable
    - args: "fix-nonhinting $in $out"
      exe: "gftools"
      operation: exec
    # doing the following instead of a "rename" operation also updates the instance postscript names
    - args: "rename-font $in 'Familyname Variable' && cp $in $out"
      exe: "gftools"
      operation: exec

This might have unintended consequences, which I’ll have to keep an eye on, but it seems to solve my immediate issue. I’m closing this issue, as I am satisfied with this answer.