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

[instancer] Start avar2 instancing #3485

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft

[instancer] Start avar2 instancing #3485

wants to merge 21 commits into from

Conversation

behdad
Copy link
Member

@behdad behdad commented Apr 18, 2024

Just some code for now to get min/max delta of a
varIdx from a varStore...

@behdad behdad marked this pull request as draft April 18, 2024 22:20
@behdad
Copy link
Member Author

behdad commented Apr 19, 2024

Just thinking out loud, this is what I think so far:

  • Say we're dealing with a HOI-style avar2. That is, there's wght and wgt2, the latter being completely driven by wght; and hidden. Both have a range of 100:400:1000; Now, if you instantiate to limit wght to, say, 400..700, we, ideally, will deduce that wgt2 can only vary from 400..700 as well, and change it's fvar to reflect that.

Because of the above, I wrote the code that taken axis limits, tells you what the min/max of each axis can be in the VarStore. Eg.:

$ time ~/fonttools/fonttools varLib.instancer.avar RobotoFlex-avar2.ttf slnt=.4 wght=500
{'slnt': (0, 0, 0, 10, 0), 'wght': (0.200012, 0.200012, 0.200012, 300, 500)}
GRAD 0.11226271092891693 (-1.44036865234375, 0.56378173828125)
slnt 0.0 (0.0, 0.0)
XOPQ 0.11226271092891693 (-1.44036865234375, 0.56378173828125)
YOPQ 0.09091131016612053 (-1.34844970703125, 0.52490234375)
XTRA -0.016883354634046555 (-1.40167236328125, 2.11279296875)
YTUC 0.0 (-1.0, 1.0)
YTLC 0.01033998653292656 (-1.7003173828125, 1.362060546875)
YTAS -0.009705182164907455 (-1.380615234375, 1.00970458984375)
YTDE 0.0 (-1.10980224609375, 1.02593994140625)
YTFI 0.0 (-1.0, 1.0)
wght 0.0 (0.0, 0.0)
wdth 0.0 (0.0, 0.0)
opsz 0.0 (0.0, 0.0)

Problem arises if the user wants to modify these hidden axes as well. Then it's not clear if we should limit their range or not :(. But I'd argue that the parametric axes in RobotoFlex and alike should be public, not private.

The code above is not complete to compute new axis extents though. Remember that we add the delta for the axis to its currently set value. So the code should take that into consideration. In which case, eg, wdth above should take (-1.0, 1.0) as its extents.

After deciding the normalized new range of each axis, we need to work them back from the avar1-segments to get new fvar values. And then build a new varStore for axes that scales the individual values based on the new axis extents.

That's my thinking.

@behdad behdad changed the title [instancer] Start avar2 subsetting [instancer] Start avar2 instancing Apr 19, 2024
@behdad
Copy link
Member Author

behdad commented Apr 19, 2024

@davelab6 We really need those avar2 test fonts for various use-cases...

@behdad
Copy link
Member Author

behdad commented Apr 19, 2024

cc @anthrotype

@behdad
Copy link
Member Author

behdad commented Apr 19, 2024

@justvanrossum

@behdad behdad force-pushed the avar-instancing branch 2 times, most recently from 7fce9f4 to d66ad1d Compare April 19, 2024 23:32
Seems to be working now.
@behdad
Copy link
Member Author

behdad commented May 4, 2024

This kinda seems to work now, even though it's not complete. I need testers like @Lorp

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

Successfully merging this pull request may close these issues.

None yet

1 participant