googlefonts / fontmake

Compile fonts from sources (UFO, Glyphs) to binary (OpenType, TrueType).
Apache License 2.0
780 stars 93 forks source link

Generating fonts from Designspace failed: ('an integer is required (got type NoneType)', ... #883

Open ryanbugden opened 2 years ago

ryanbugden commented 2 years ago

Hi, I'm experiencing an inability to generate a variable font with fontmake [designspace file] -o variable. I'm getting the following error that I don't know how to interpret.

...
INFO:fontTools.varLib:Generating HVAR
INFO:fontTools.varLib:Merging OpenType Layout tables
INFO:fontTools.varLib:Generating gvar
INFO:fontTools.varLib:Merging TT hinting
INFO:fontTools.varLib:Generating GSUB FeatureVariations
INFO:fontTools.varLib:Setting OS/2.usWeightClass = 1
fontmake: Error: In '[path to designspace file]': Generating fonts from Designspace failed: ('an integer is required (got type NoneType)', 'Substitute[]', 0, 'SubTable[]', 1, 'Lookup[]', 'LookupList')

I'm stumped! Any leads would be greatly appreciated.

BoldMonday commented 2 years ago

INFO:fontTools.varLib:Setting OS/2.usWeightClass = 1

That value for usWeightClass in the OS/2 table looks very weird. Did you check the usWeightValues in the font info?

belluzj commented 2 years ago

Are the rules OK, like do they all have min and max?

Could you out of curiosity try to compile with this fontmake pre-release:

In your venv: pip install fontmake==3.4.0a1

Maybe (no guarantee) the error message might be different.

ryanbugden commented 2 years ago

Thanks for the replies, you two!

@BoldMonday I thought so too; although I don't know what's causing it... My sources are all set to either 400 or 900.

@belluzj I gave that a shot, and it looks like the error message is the same.

As far as my substitution rules... maybe bad glyph naming?

  <rules>
    <rule name="currency bars">
      <conditionset>
        <condition name="Weight" minimum="500" maximum="1000"/>
        <condition name="Optical Size" minimum="8" maximum="48"/>
      </conditionset>
      <sub name="dollar" with="dollar.alt"/>
      <sub name="cent" with="cent.alt"/>
      <sub name="dollar.tab" with="dollar.tab.alt"/>
      <sub name="cent.tab" with="center.tab.alt"/>
    </rule>
  </rules>
ryanbugden commented 2 years ago

Deleting the rules and then rebuilding them seems to have solved it for now. But I have no idea why.

  <rules>
    <rule name="currency bars">
      <conditionset>
        <condition name="Weight" minimum="500" maximum="1000"/>
        <condition name="Optical Size" minimum="8" maximum="48"/>
      </conditionset>
      <sub name="dollar" with="dollar.alt"/>
      <sub name="cent" with="cent.alt"/>
      <sub name="dollar.tab" with="dollar.tab.alt"/>
      <sub name="cent.tab" with="cent.tab.alt"/>
    </rule>
  </rules>
belluzj commented 2 years ago

From your second version, it looks like it was bad glyph naming: image

We should probably intercept this problem and print a good error message...

ryanbugden commented 2 years ago

Wow can't believe I didn't catch that. Thank you @belluzj !

Still curious why usWeightClass snaps to 1. Any idea?