sannorozco / amstelvar-avar2-OLD

SIL Open Font License 1.1
0 stars 0 forks source link

implementing fences #6

Closed gferreira closed 9 months ago

gferreira commented 9 months ago

I've been trying to implement fences in avar2 for AmstelvarA2.

some background on what fences are:

Designspace fences (Mom, You Sure Can Rehydrate a Pizza)

Fences keep users to “safe” or “approved” zones of the designspace.

Users who choose axis settings that are beyond the fence will be brought back inside the safe zone.

in other words, fences restrict the scope of parametric axes (XOPQ XTRA YOPQ XTSP) depending on the current location in blended axes (wght wdth).

the min/max values for each parametric axis, at each blended extrema for wght and wdth (duovars), were defined by @dberlow here as a RTF document:

http://github.com/gferreira/amstelvar-avar2/blob/main/Source/Parametric-avar2/Roman/Amstelvar%20avar2%20DSL.1.rtf

the relevant fences data was then extracted into this JSON file:

http://github.com/gferreira/amstelvar-avar2/blob/main/Source/Parametric-avar2/Roman/fences.json

finally, this data is used to add new mappings to the avar2 .designspace file using the fontTools API.

for example, at wght=400 we would like to limit parametric axes to the following min/max values:

"wght400": {
  "XTRA": {
    "min": 300,
    "max": 450
  },
  "XOPQ": {
    "min": 72,
    "max": 110
  },
  "YOPQ": {
    "min": 50,
    "max": 75
  },
  "XTSP": {
    "min": -60,
    "max": 50
  }
}

in designspace XML this becomes the following: (only XTRA shown)

<mapping>
  <input>
    <dimension name="Weight" xvalue="400"/>
    <dimension name="XTRA" xvalue="208"/>
  </input>
  <output>
    <dimension name="XTRA" xvalue="300"/>
  </output>
</mapping>
<mapping>
  <input>
    <dimension name="Weight" xvalue="400"/>
    <dimension name="XTRA" xvalue="508"/>
  </input>
  <output>
    <dimension name="XTRA" xvalue="450"/>
  </output>
</mapping>

in plain language: when the weight value is 400, instead of going all the way down to 208, the user can only go until 300; and instead of going all the way up to 508, the user can only go until 450.

such fence mappings were added for the default and for all blended extrema (wght200 wght800 wdth85 wdth125), for parametric axes XTRA XOPQ YOPQ XTSP only. the resulting designspace and variable font are here:

http://github.com/gferreira/amstelvar-avar2/blob/main/Source/Parametric-avar2/Roman/AmstelvarA2-Roman_avar2_fences.designspace http://github.com/gferreira/amstelvar-avar2/blob/main/fonts/AsciiAlpha/AmstelvarA2-Roman_avar2_fences.ttf

the fences effect seems to be working at the default location (wght400 wdth100): the scope of XOPQ XTRA YOPQ XTSP is limited when these parametric axes are used alone or in combination with each other. fences for the blended extrema, however, are not working as intended; the fenced values seem to be morphing back to the default (?).

a second designspace and variable font were created containing fences for one only blended extrema (wght200):

http://github.com/gferreira/amstelvar-avar2/blob/main/Source/Parametric-avar2/Roman/AmstelvarA2-Roman_avar2_fences-wght200.designspace http://github.com/gferreira/amstelvar-avar2/blob/main/fonts/AsciiAlpha/AmstelvarA2-Roman_avar2_fences-wght200.ttf

also here the fences for the blended extrema wght200 are not working as intended.


some questions at this point:

gferreira commented 9 months ago

cc @Lorp @behdad thanks in advance for any feedback you can give on this!

gferreira commented 9 months ago

oops. issue moved to the main AmstelvarA2 repository: http://github.com/googlefonts/amstelvar-avar2/issues/4