Variable font. Mapping `wght`

Hi!
Is it possible to remap the font weights of a OT Var font?
This would help me to set range from 100 to 900, as the CSS standard weight class.
In a .designspace file it would be something like:

  <axes>
    <axis tag="wght" name="Weight" minimum="100" maximum="900" default="400">
      <map input="100" output="30"/>
      <map input="200" output="44"/>
      <map input="300" output="63"/>
      <map input="400" output="82"/>
      <map input="500" output="100"/>
      <map input="600" output="123"/>
      <map input="700" output="153"/>
      <map input="800" output="182"/>
      <map input="900" output="214"/>
    </axis>
    <axis tag="opsz" name="Optical size" minimum="10" maximum="40" default="30"/>
  </axes>

Thanks!
Juan

With ttx. I’ll post the code tomorrow.

1 Like

It would be great to have a custom parameter for doing this :slight_smile:

What you want to change is the MaxValue of an Axis definition inside the fvar table.

Easiest way to do this is with OTMaster. It has a straight forward UI, you open the font, look for fvar, open its Axis definitions, and change the MaxValue entries, and save the file, done.

If you want to do it with ttx, you furst need to take the hurdle of installing fonttools. Best guess is to paste this in Terminal, and to hope it works:

python3 -m pip install fonttools

This makes a command called ttx available, which can convert your OpenType font into XML and back again.

  1. So, first, you need to extract the fvar table. cd into the same directory as your font, and use this:
    ttx -t fvar "font.ttf"
    Instead of font.ttf, use the name of the font file. (Hint: you can also drag and drop into the Terminal window.)
  2. Open the resulting .ttx file in your favorite plaintext editor (I recommend Sublime Text, TextMate, BBEdit or Atom), look for the <MaxValue> tag, and change the value there. Save the file again.
  3. Merge (-m) the .ttx back into the .ttf:
    ttx -m "font.ttf" -o "font.ttf" font.ttx
    The -o option overwrites the existing file, rather than creating another copy.

Now the .ttf should have a new maximum for the respective axis.

Thanks Rainer!