fonttools / fontbakery

🧁 A font quality assurance tool for everyone
https://fontbakery.readthedocs.io
Apache License 2.0
534 stars 99 forks source link

Support setting variations in update_shaping_tests input #4753

Closed khaledhosny closed 4 weeks ago

khaledhosny commented 1 month ago

If input.variations is explicitly set, it will be used instead of using instance coordinates from fvar table.

Checklist

felipesanches commented 1 month ago

@madig, since @khaledhosny requested you to review this PR, I'll wait your OK before merging this. Let me know what you think.

madig commented 1 month ago

This is for testing one specific location?

khaledhosny commented 1 month ago

This is for testing one specific location?

For testing arbitrary locations in general. I build variable fonts that has don’t always have named instances for locations I want to test.

khaledhosny commented 1 month ago

Here is an example TOML file from the project I needed this for. The only fvar instance has MSHQ=10, but I want to test its extreme as well:

[input.variations]
MSHQ = 100

[input]
script = "arab"
direction = "rtl"
text = [
    "ص ص‍ ‍ص‍ ‍ص",
    "ض ض‍ ‍ض‍ ‍ض",
]

With this PR, it generates this JSON file:

{
  "tests": [
    {
      "only": "Astrolabe.ttf",
      "input": "ص ص‍ ‍ص‍ ‍ص",
      "expectation": "uni0635.fina=10+1750|space=8+0|space=8+0|space=6+0|uni0635.medi=6+1350|space=4+0|space=4+0|space=2+0|uni0635.init=2+1350|space=1+0|uni0635=0+1700",
      "script": "arab",
      "direction": "rtl",
      "variations": {
        "MSHQ": 100
      }
    },
    {
      "only": "Astrolabe.ttf",
      "input": "ض ض‍ ‍ض‍ ‍ض",
      "expectation": "dotabovear=10@672,250+0|uni0635.fina=10+1750|space=8+0|space=8+0|space=6+0|dotabovear=6@262,250+0|uni0635.medi=6+1350|space=4+0|space=4+0|space=2+0|dotabovear=2@661,250+0|uni0635.init=2+1350|space=1+0|dotabovear=0@1037,250+0|uni0635=0+1700",
      "script": "arab",
      "direction": "rtl",
      "variations": {
        "MSHQ": 100
      }
    }
  ]

Without setting input.variations, it will be "MSHQ": 10.0.