Open Lorp opened 2 months ago
The logic is actually pretty simple:
See this comment for how that logic can fail: https://github.com/fonttools/fonttools/issues/3086#issuecomment-2263626285
Thanks for the discussion. Indeed the corners definitely need to be considered for representation as mappings. Trying now with this logic:
Will it work to take 2^n+1 locations from every region encoded in the IVS? (where n=number of dimensions having value!=default, thus encoding all of the n-D region’s corners, and the +1 is for the n-D peak). Then we transform the unique locations with the IVS to obtain the deltas, and thereby the mappings.
It seems to work well on arbitrary mappings on a 2-axis font, except for adding some redundant pin mappings. Amstelvar seems not to be working however.
@behdad @justvanrossum if you care to take a look, the code is here.
https://github.com/Lorp/fencer/blob/82d572753ff81865f9bb32b2f5a5767f249e37d0/src/fencer.js#L709-L779
@behdad @justvanrossum if you care to take look, the code is here.
The Fontra link is outdated now?
Yes, since we’re agreed that a tent’s start and end need to be accounted for, as well as peak.
@behdad @justvanrossum if you care to take look, the code is here.
Looks about right, except that part about getting delta from first ivsd?
@behdad @justvanrossum if you care to take look, the code is here.
Looks about right, except that part about getting delta from first ivsd?
I actually don't fully understand that comment.
Ah, that’s an old comment. It does handle multiple IVDs. I’ll delete.
Hang on, there is a bug there (the [0] index at the end), which will affect IVDs after the 0th one. On it…
Now uses [ivdIndex] instead of [0].
Currently Fencer ignores any existing avar data, though it would be very useful if it could visualize existing avar1 and avar2 data as mappings.
Although a general solution may not be possible, it should be possible at least in all the cases where the avar2 table was compiled from mappings, which includes all fonts made via a .designspace document and all fonts exported from Fencer.
This code from Fontra is suggested by @justvanrossum, as noted in https://github.com/fonttools/fonttools/issues/3086
https://github.com/googlefonts/fontra/blob/087fac4c01d5bbd918f3550d03fae5693f0dc292/src/fontra/backends/opentype.py#L255-L285