Skip to content

Instantly share code, notes, and snippets.

@davelab6
Last active June 3, 2019 14:45
Show Gist options
  • Save davelab6/42c025f630589d2a0154ecf697735db9 to your computer and use it in GitHub Desktop.
Save davelab6/42c025f630589d2a0154ecf697735db9 to your computer and use it in GitHub Desktop.

Is the 'wdth' axis Regular at 100?

If a variable font has a 'wdth' (Width) axis, then the coordinate of its 'Regular' instance is required to be 100, according to the OpenType specification's "registered axis" definition of wdth, available at https://docs.microsoft.com/en-gb/typography/opentype/spec/dvaraxistag_wdth

Conditions

Run this when the font...

  • is a variable font
  • has a wdth axis

Pass Message

Regular:wdth is 100.

Fail Reason

The 'wdth' coordinate of the 'Regular' instance must be 100, but instead the default value is {regular_wdth_coord}.

Related Information

Where was this requested?

fonttools/fontbakery#1707

Fonts that will pass this check

cabinvfbeta/Cabin-VF.ttf

Check the fonts

if regular_wdth_coord == 100:
  yield PASS, pass_message
else:
  yield FAIL, fail_message["reason"]

Test the check

Our reference varfont has a good Regular wdth coordinate, so it should PASS the test:

regular_width_coord = regular_wdth_coord(ttFont)
print('Test PASS with a good Regular:wdth coordinate...')
status, message = list(check(ttFont, regular_width_coord))[-1]
assert status == PASS

We then change the value so it must FAIL:

ttFont["fvar"].instances[0].coordinates["wdth"] = 0

Then re-read the coord:

regular_width_coord = regular_wdth_coord(ttFont)

and now this should FAIL the test:

print('Test FAIL with a bad Regular:wdth coordinate (100)...')
status, message = list(check(ttFont, regular_width_coord))[-1]
assert status == FAIL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment