ufoProcessor icon indicating copy to clipboard operation
ufoProcessor copied to clipboard

Calculate instance values for openTypeOS2WidthClass, openTypeOS2WeightClass?

Open LettError opened this issue 2 years ago • 3 comments

Under some conditions it should be possible to calculate meaningful values for openTypeOS2WidthClass and openTypeOS2WeightClass, when generating instances.

openTypeOS2WidthClass

wdth conditions:

  • https://learn.microsoft.com/en-us/typography/opentype/spec/os2#uswidthclass
  • value between 50 - 120 ?

openTypeOS2WeightClass

wght conditions:

  • https://learn.microsoft.com/en-us/typography/opentype/spec/os2#usweightclass
  • value between 100 - 900

General considerations:

  • Anisotropic locations should not be a problem as these are horizontal attributes.
  • Extrapolation: values could be clipped to prevent unexpected outcomes like negative values.
  • Values are expected to be user space values, so appropriate mapping has to happen.

Pro: these can be fussy values to set in a build script. Width may be more difficult to get right as it only has 9 values it can be. Weight, on the other hand, has a bigger range. Con: not every designspace will fit the conditions and that means ufoOperator will not always to the math. And that may be confusing.

LettError avatar Sep 22 '23 11:09 LettError

fontMath already does something with those info attributes: https://github.com/robotools/fontMath/blob/777dd889e4431d5b4666f032bdf1269d2ccf37b0/Lib/fontMath/mathInfo.py#L381

Is there something else necessary

typemytype avatar Sep 22 '23 12:09 typemytype

Fontmath will indeed interpolate the values in the source files. I suppose the idea is that the source values can be inferred from the location in the designspace, independent from what is stored in the source.

LettError avatar Sep 22 '23 13:09 LettError

mmm I see

something that overwrites those interpolated values (extracted from the sources, which could be different then the location of the instance) based on the wght and wdth locations...

typemytype avatar Sep 22 '23 14:09 typemytype