"Fix a bug with interpolations in certain setups"

Hi,

I upgraded from 2.4 (1075) this morning and started to check if I would get differences generating fonts. As first step I performed a diff with the old file, saved a new version without making edits. I discovered different instanceInterpolations values. And when generating font, there were outline differences where the values were different.

First I tried looking at the differences with 1075, but then added a file last saved with 983. I saved copies of this file with 1075 and 1131.

For interpolations between 2 masters it seems that 1075 and 1131 drop a decimal digit, which may or may not result in a small difference here or there, but probably not.

As my set-up has 4 masters for the normal widths (Light, Regular, Semi-Bold and Bold) and 3 for the narrow widths (Light, Regular and Bold), there will be instances interpolated with 3 masters (in the semi-bold range). Here 1075 seems to have been using 4 masters instead. The values of 983 and 1131 match, apart from the difference in precision. And checking the math, the values are correct. So this must have been a bug in 1075, which may the fix that the change log mentioned for 1129.

And then there are interpolations between 4 masters.

Possible to have all 3 versions the same values, apart from losing a digit.
Possible to have 1075 and 1131 the same but with a not insignificant difference with 983.
Possible to have everything different.

I haven’t tried going deeper and checking out the math. Not sure if I should be using 1131 or 983 for generating fonts. Hope that Georg can look into it and provide explanations or advice.

Thanks,
Jelle

That entry in the change log was referring to this forum thread: 2.5b new issues
We almost rewrote the algorithm that calculates the instanceInterpolations. If you are not happy with the values in the latest version, could you send me the files that I can add them to our testing setup?

The instanceInterpolations values in the files are not actually used, they are just written out that other toolchains might use them.

1 Like

I don’t know if I am happy with the values in the latest. I checked two of them. One case where 983 and 1131 had the same value, 1075 is wrong and I have spend quite a while looking at a wrong interpolation and releasing it. This morning I calculated another interpolation and found that I got the same result as 1075 and 1131, different from 983. As you say, instanceInterpolations values do not need to be stored in the file, as the interpolation values should be sufficient to work out the interpolations. At least in my set-up I would not expect ambiguity. And as I am working on Noto Indics, these files are intended for another tool chain, which may, or may not get the same results for the interpolations. Up to recently it could not handle the 7 master set-up.

So I guess I have to find some time to work my way through all interpolations to see what is going on. But not today.

Please send some example files. You can remove most glyphs, I mostly need the master and instance setup.

Georg, I will send you files.

This is a graph comparing values from app versions 983, 1075 and 1131. A weight-width interpolation with 3 narrow and 4 wide-width masters: instances for 9 weights and 4 widths. The lowercase x shows differences in multiplication values. The uppercase X where the number of masters used differs too. I verified by comparing hmtx tables, that differences show up in generated fonts too.

Untitled

Between V983 and V1075 the intermediates with weight 39 have changed. In my calculation I get the same results as the latter two and 1075 and 1131 are OK.

Between weights 90 and 190 the version 1075 seems a fluke. It uses 4 masters where I expect 3 and 3, 4 or 5 when it should be 4.

In row with weight 151, the “missing master row”, version 983 and 1131 agree. And so do I. The narrow 151 is expressed by the two multiplication values given by its position between 90 and 190. So the intermediates are calculated from 3 masters. The 2 weight values of the narrow (that add up to 1) and the one weight value of the wide (which is 1) are multiplied with the respective width values. That gives three values, that add up to 1.

I don’t know why Glyphs gives 3 different results for the rows 108, 128 and 169. And my calculation gives a different 4th. Currently I do not see what I am doing wrong. For my calculation it makes no difference how many intermediate masters there are. The interpolation values are derived from relative positions in the grid. It does not matter if on the other side of an interpolation there is instance with multiplication value 1 or with 2 multiplication values that add up to 1, because that is 1 too.

I’ll have my calculation checked. If it is OK, it will be forwarded.

Jelle

In those set-ups, there is not one correct result. One has to decide what he wants. Less masters used, least amount of extrapolation…

You are describing it rather vague, but I think I got you.

In the rows 108, 128 and 169 where I see differences between values for Condensed Semi Bold between app version 983 and 1131, that is because I expect values that resolve into an interpolation between 128-70 and 128-100. Both 983 and 1131 use values that resolve into an interpolation between 131-70 and 121-100, which is a different way of getting at 128-79. By having 983 and 1131, for one reason or another, using a slightly different angle, I do get rounding differences in the two fonts generated from the same source.
The fonts generated from app version 1075 are a different story. Here I get differences of more than 1 unit. In the Condensed Bold I get a hmtx diff of 5 units. So indeed 1131 fixes a bug with interpolations in certain set-ups, at least in my set-up.

The problem is, if I see differences in fonts generated from the same source, I don’t know what to trust.

As mentioned in the other thread, one thing you can always do is to use the “Disable Masters” custom parameter to control the interpolation.

In some cases, this is interesting to play around with in any case and often you will need to visually judge whether disabling masters (and which ones) leads to the most convincing results. Sometimes it’s a tough call even for us designers.

So, in your two-axis set-up, if you disable all except three masters (i.e. one more master than the number of axes), then the interpolation is clearly defined and you can be sure that you will get exactly the same final result in all (including future) versions of Glyphs because the algorithm has no choice an there is only one correct set of coefficients to calculate the instance.

I am in a bit of a spin about these differences this week. Even more so because I am working exclusively on Noto Indics, so the final fonts will be generated by Google’s tool which means more possibilities for differences. Initially their tools could not handle the set-up at all. It took some explanation.

At a resolution of 1000 units per EM, any interpolation is an approximation.
So what I understand now is that for some reason the interpolation values that V983 and V1131 are using should be giving the same approximation as the values that I am using. But because the values are different, the rounding is different because of the precision of the used variables. Why 983 and 1131 are using different values I do not understand. But it seems the differences between the two versions are rounding differences. But I haven’t checked all values of all fonts.

V1075 that I have been using for quite a while, is a different beast. In three places it uses a different number of masters. If I with “Disable Masters” I exclude the Regular in the two Bold intermediates of row 151, then 1075 gives exactly the same results as 1131.

It does not help in the other three rows. At 169 - 89 V1075 uses 3 masters, rather than 4, and I cannot Disable anything. At 169 - 79 V1075 uses 5 masters. If I exclude the regular there, then I still get differences that are too large to be rounding.

Versions 983 and 1131 are different but probably OK. Version 1075 had a bug that must have been fixed.

With Googles toolchain you might get into trouble with this setup. At least you should test that extensively.
You could add a “Semibold Condensed” master automatically.

Tell me about it… It seems it has been fixed recently, but I haven’t tested it. (I am now hoping they haven’t checked their work by comparing with output from Glyphs 1075!)

I am afraid, I am starting to question this.

It seems a daunting task to work out code that calculates interpolation values for any arbitrary combinations of instances and masters. But in my set-up I don’t see more than 1 solution.

When looking at the interpolation multiplication values for Condensed Semi-Bold (128 -79) of the different versions, these resolve for me as follows.

1131 interpolates between 130.80 - 70 and 121.25 - 100
983 interpolates between 131.21 - 70 and 120.5 - 100
1075 interpolates between 133.4 - 70 and 116.25 -100

In all three cases we end up in the interpolation grid at position 128 - 79. But they are different and it is not by rounding.
This being a sans serif with even proportions, the small differences between 1131 and 983 are in the order of a rounding error, but that is because of the grid and the rather even proportions of the design. If I give a wide character a very small advance width in the regular, the difference between 121.25 and 120.5 is large enough to get much more than a rounding error. The more differences in the proportions of the masters, the larger the angle of the interpolation, the more differences in the calculation.

So I am in a situation where we have 9 extra condensed instances, interpolated with 3 extra condensed masters. There doesn’t seem more than one correct math result here. If I don’t like the visual result I should change the interpolation weight values, or the drawings, until I do.
For the normal width I have 4 masters for the 9 instances, and no ambiguity in the math.

The Condensed is defined by the width interpolation values as being 70% of the extra condensed and 30% of the normal width. And for 6 of the 9 condensed instances that is true in version 1131. For the Thin, regular and Black that is a straight interpolation between masters. For Extra Light, Light and Bold the multiplication values give me an interpolation that is a straight interpolation between interpolated instances of the same weight.

But for the Condensed Medium, Semi Bold and Extra Bold I get something else. It is puzzling that the missing master causes a change in the math used for the surrounding rows, while the row with the missing master is not different from what it would have been if it wasn’t missing*. It seems when I generate fonts I have to add an interpolated Extra Condensed Bold masters and remove it once done**.

  • one rounding difference in the hmtx.

** but for version 983 I will have to interpolate 11 instances and add them as masters.