googlefonts / googlefonts/fontmake

Instantiator usWidthClass

Open
#926 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
888
Forks
97
Avg merge
4d 52m
Merged PRs (30d)
1

Description

We are having an issue with the instantiator regarding `usWidthClass`.
Our Variable font 'wdth' axis spans from 50 to 275 (%) but the instantiator tries to map it to 50-200 because of the example of the OpenType specs:
https://docs.microsoft.com/en-us/typography/opentype/spec/os2#uswidthclass
https://github.com/googlefonts/fontmake/blob/24312140ce114691363f62b9293c46b10f95c0b4/Lib/fontmake/instantiator.py#L633

Why should the 'wdth' need to stick to the min=50 max=200 example of the specs? a variable font may as well have very different min-max values and still the named instance would need distinctive `usWidthClass` values.

In our case the last two wider instances get the same usWidthClass value of 9 (because both are beyond 200) and this is creating the confusion.

`width_user_value = min(max(wdth_user_value, 50), 200)`: wouldn't it be more correct to replace the arbitrary values of 50 and 200 by the VF `wdth max` and `wdth min` then map accordingly the instances values?

Contributor guide

Open the contributing guide

Research direction

Start in Lib/fontmake/instantiator.py around line 633 and read the OpenType usWidthClass specification linked in the issue. Trace how wdth user values are converted for named instances, then determine how distinct values beyond the 50–200 example should be represented. Done means the mapping no longer collapses the wider instances and the relevant behavior is covered by the project’s existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.