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

[write-fonts/gvar] add axis_count param to Gvar::new #919

Merged
merged 2 commits into from
May 30, 2024

Conversation

anthrotype
Copy link
Member

this ensures that we (e.g. fontc) can make valid empty gvar tables where the axis_count matches the expected (fvar's) axis_count as per OT spec.

Will eventually fix googlefonts/fontc#815 once fontc is updated to use the new API.

This is a breaking changes which warrants minor write-fonts version bump.

this ensures that we (e.g. fontc) can make valid empty gvar tables where the axis_count matches the expected fvar's axis_count

Will fix googlefonts/fontc#815 once fontc is updated to use the new API.

This is a breaking changes which warrants minor write-fonts version bump.
anthrotype added a commit to googlefonts/fontc that referenced this pull request May 29, 2024
Fixes #815

Untested as it requires googlefonts/fontations#919 (and write-fonts dependency bump) to work...
@cmyr
Copy link
Member

cmyr commented May 29, 2024

Okay so to understand the situation here: sometimes we would like to have an empty gvar table, but set an explicit axis_count?

If yes: is it true that there are basically two ways we expect the new API to be called:

  • previously, where the axis_count could be inferred from the input
  • the empty case, where there are no variations but we want a non-zero axis count?

If yes, my one nit with this PR is that it introduces a new error and possible error condition that we might be able to avoid. For instance, we could have a separate constructor Gvar::empty(axis_count: u16) that would handle this case, and since there would be no provided variations we wouldn't need to worry about a possible error?

That does push the responsibility down to the caller, to ensure that they call a different constructor to get an empty table, so there is that downside.

What do you think?

@anthrotype
Copy link
Member Author

sometimes we would like to have an empty gvar table, but set an explicit axis_count?

yes, because some old apps expect gvar to always be present in a VF even if empty, and the spec wants gvar's axis_count == fvar.axis_count no matter what (e.g. fonttools fails to decompile an empty gvar with axis_count of 0 where fvar.axis_count != 0)

previously, where the axis_count could be inferred from the input...

technically it would still be possible for the caller to construct a gvar table where all the provided variations have the same, consistent axis_count, but the latter turns out not to match the global fvar's axis_count, but you could argue that's not write-font's fault.

But I'm not opposed to the proposed additional Gvar::empty(axis_count) constructor either. I think we are splitting hairs for an arguably-very-limited use case so whatever makes you guys happy. /cc @rsheeter

@cmyr
Copy link
Member

cmyr commented May 29, 2024

My preference is just for simpler code and fewer error conditions, but agree it's not a big deal.

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor preference for the alternative version I think but merge this if you prefer!

@anthrotype
Copy link
Member Author

I think I can wait until tomorrow to let @rsheeter chime in. Feel free to cut a release without this or wait

@anthrotype anthrotype requested a review from rsheeter May 29, 2024 17:17
@anthrotype anthrotype merged commit e2a07db into main May 30, 2024
9 checks passed
@anthrotype anthrotype deleted the gvar-axis-count-param branch May 30, 2024 14:23
anthrotype added a commit that referenced this pull request May 30, 2024
#919 contains a backward incompatible change (new axis_count parameter added to Gvar::new constructor)
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.

Variable GPOS feature for non-variable glyph? (invalid gvar axisCount)
3 participants