Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instantiation from Glyphs source: usWeightClass is set wrong #615

Closed
yanone opened this issue Dec 12, 2019 · 16 comments
Closed

Instantiation from Glyphs source: usWeightClass is set wrong #615

yanone opened this issue Dec 12, 2019 · 16 comments

Comments

@yanone
Copy link
Contributor

yanone commented Dec 12, 2019

When creating static instances from a Glyphs source, the instance’s interpolation space weight value is used for usWeightClass as opposed to the appropriate weight class value.

I had actually added a weightClass custom parameter to each instance using the simple script below, so the custom parameter should be used for usWeightClass when present, or otherwise calculated in fontmake on the fly as below:

from GlyphsApp import *
f = Glyphs.font

weights = {
'Thin': 100,
'ExtraLight': 200,
'UltraLight': 100,
'Light': 300,
'Normal': 400,
'Regular': 400,
'Medium': 500,
'DemiBold': 600,
'SemiBold': 600,
'Bold': 700,
'UltraBold': 800,
'ExtraBold': 800,
'Black': 900,
'Heavy': 100,
}

for i in f.instances:
	i.customParameters['weightClass'] = weights[i.weight]
@yanone
Copy link
Contributor Author

yanone commented Dec 12, 2019

The same thing goes for VF instances. It's the same source, the instances have a weightClass custom parameter.

 >> com.google.fonts/check/varfont_instance_coordinates
    Check variable font instances have correct coordinate values
    with ./Fonts/vf/Petrona[wgth].ttf

    * FAIL: Instance "Thin" wght value is "32.0". It should be "100.0" [code: bad-coordinate]
    * FAIL: Instance "ExtraLight" wght value is "40.0". It should be "200.0" [code: bad-coordinate]
    * FAIL: Instance "Light" wght value is "49.0". It should be "300.0" [code: bad-coordinate]
    * FAIL: Instance "Regular" wght value is "61.0". It should be "400.0" [code: bad-coordinate]
    * FAIL: Instance "Medium" wght value is "76.0". It should be "500.0" [code: bad-coordinate]
    * FAIL: Instance "SemiBold" wght value is "94.0". It should be "600.0" [code: bad-coordinate]
    * FAIL: Instance "Bold" wght value is "117.0". It should be "700.0" [code: bad-coordinate]
    * FAIL: Instance "ExtraBold" wght value is "145.0". It should be "800.0" [code: bad-coordinate]
    * FAIL: Instance "Black" wght value is "180.0". It should be "900.0" [code: bad-coordinate]

    Result: FAIL

@arrowtype
Copy link

arrowtype commented Dec 12, 2019

Small nitpick in your script:

I think probably 'Heavy': 100, should be 1000, correct?

@yanone
Copy link
Contributor Author

yanone commented Dec 12, 2019

Oh, you're right. But I took the values from Glyphs UI, and there it says 900, not 1000. But 100 is wrong anyway. Thanks.

@anthrotype
Copy link
Member

That's unexpected. It could be something in glyphsLib.
Have you got source files to share so we can take a look?
thanks

@yanone
Copy link
Contributor Author

yanone commented Dec 12, 2019

@anthrotype
Copy link
Member

how did you build the VF exactly?
fontmake -g MyFont.glyphs -o variable or something fancier?

@yanone
Copy link
Contributor Author

yanone commented Dec 12, 2019

Just like that

@anthrotype
Copy link
Member

oh I see. You have "Axis Location" custom parameters for the masters, but the values are in internal design coordinates. They are meant to define the user-space coordinates of the masters.

@yanone
Copy link
Contributor Author

yanone commented Dec 12, 2019

And user-space coordinates are usWeightClass values?
Thing is, the font doesn't compile without Axis Location parameters: ufo2ft.errors.InvalidDesignSpaceData: Can't find base (neutral) master in DesignSpace document

@anthrotype
Copy link
Member

yea.. Because none of your instances locations correspond to one of the masters, and when Axis Location params are missing, glyphsLib will infer the master's user-space location from the corresponding instances.
We really need to add support for the new Axis Mapping custom parameter... /cc @madig @belluzj

@m4rc1e
Copy link
Contributor

m4rc1e commented Dec 12, 2019

Yanone, I'm attaching a .glyphs file which will build.

I did the following:

  • Turn Medium instance into a master
  • Delete Regular instance since no instances can match it (as Cosimo pointed out)
  • Delete bracket layers in Peso.

You will need to readd the bracket layers in the peso and add them for each later. I deleted them so I could just get a working build.

Petrona-ROMAN-MASTER-NEW-W_mf_tweak.glyphs.zip

@anthrotype
Copy link
Member

currently glyphsLib has two alternative ways to define the Designspace axes mappings (that will go into avar).

  1. via Axis Location custom parameters which are set on the masters only
  2. by inferring the master's user-space locations from the instances that have the same internal design location as a master

The problem with 1) is that it only allows to set user->internal mappings for the masters, but not for anything in between.
The problem with 2) is that it is implicit and thus obscure, and also one needs to have at least as many instances as there are masters

We need to support a new method introduced recently called "Axis Mapping" that allows more flexibility in defining these mappings.
need to find the time to understand how it works.
If you'd like to research a bit and let us know how it is supposed to work, it'd greatly help.

@anthrotype
Copy link
Member

for background see googlefonts/glyphsLib#568 and googlefonts/glyphsLib#483

@yanone
Copy link
Contributor Author

yanone commented Dec 12, 2019

So for understanding, I set the Axis Location parameter to the weightClass of their respective instances. The problem you described in 1) is this?:

 >> com.google.fonts/check/varfont_instance_coordinates
    Check variable font instances have correct coordinate values
    with ./Fonts/vf/Petrona[wght].ttf

    * FAIL: Instance "ExtraLight" wght value is "148.0". It should be "200.0" [code: bad-coordinate]
    * FAIL: Instance "Light" wght value is "202.0". It should be "300.0" [code: bad-coordinate]
    * FAIL: Instance "Regular" wght value is "274.0". It should be "400.0" [code: bad-coordinate]
    * FAIL: Instance "Medium" wght value is "364.0". It should be "500.0" [code: bad-coordinate]
    * FAIL: Instance "SemiBold" wght value is "461.2244873046875". It should be "600.0" [code: bad-coordinate]
    * FAIL: Instance "Bold" wght value is "578.5714263916016". It should be "700.0" [code: bad-coordinate]
    * FAIL: Instance "ExtraBold" wght value is "721.4285736083984". It should be "800.0" [code: bad-coordinate]

@anthrotype
Copy link
Member

Correct!

@yanone
Copy link
Contributor Author

yanone commented Dec 12, 2019

Okay, great. Thanks everyone for the quick responses. I'm closing this one here.

@yanone yanone closed this as completed Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants