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

[CFF2] Conflicting text regarding the default vsindex when processing CharStrings #157

Open
behdad opened this issue Oct 22, 2024 · 3 comments
Labels

Comments

@behdad
Copy link
Member

behdad commented Oct 22, 2024

I'm surprised at what I think I'm seeing. Please correct me if I'm wrong.

Part of the CFF2 spec says:

By default, the first ItemVariationData structure (index 0) will be used. The vsindex operator can be used for glyphs that require a different list of regions.

But then there's text that says:

The vsindex key may be used in a PrivateDICT to select a different list of regions for the group of glyphs associated with that PrivateDICT. vsindex may also be used in a CharString to select the list of regions for that glyph. When used in a CharString, it overrides a setting in the associated PrivateDICT.

And in another place:

When used within a PrivateDICT, it has effect not only for variation of values specified by PrivateDICT keys but also for variation in all CharStrings associated with that PrivateDICT. However, a vsindex operator can also be used within a CharString, taking precedence over the vsindex specified in the PrivateDICT.

Humm. So, which is it. If a CharString doesn't have a vsindex operator, is the first ItemVariationData structure (index 0) used, or the vsindex specified in the PrivateDICT is used? Looks like the intention is the latter. I find the first quotation above misleading and suggest changing it to say that it defaults to 0 in the PrivateDICT case only.

I think I have unfortunately written some code, either in FontTools or HarfBuzz, that assumes that vsindex defaults to 0 in CharString processing.

@behdad behdad added the CFF2 label Oct 22, 2024
@skef
Copy link
Contributor

skef commented Oct 22, 2024

These specifications don't really conflict, they just don't pull the whole definition into one place. I believe its:

if vsindex operator in charstring:
   vsindex = (charstring vsindex operand)
else if vsindex operator in glyph's privatedict:
   vsindex = (privatedict vsindex operand)
else
   vsindex = 0

@behdad
Copy link
Member Author

behdad commented Oct 22, 2024

What you sketch is correct indeed. But I have in the past read "By default, the first ItemVariationData structure (index 0) will be used. The vsindex operator can be used for glyphs that require a different list of regions." and assumed the glyphs default to vsindex 0 if none is specified. I'm still auditing FontTools & HB code for that assumption I might have put into code.

@skef
Copy link
Contributor

skef commented Oct 22, 2024

So we just need to tune up the language -- I'm fine with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants