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

[outlineOTF] only write PostScript BlueValues when are not empty #115

Merged
merged 2 commits into from
Mar 9, 2017

Conversation

anthrotype
Copy link
Member

@anthrotype anthrotype commented Mar 9, 2017

Currently ufo2ft writes all the four blue values (BlueValues, OtherBlues, FamilyBlues, FamilyOtherBlues) whenever either postscriptBlueValues or postscriptOtherBlues are non-empty lists in the UFO fontinfo.plist. It only checks those two, but then writes all four of them.

So even if the others are empty, they will still be compiled as empty deltas in the CFF PrivateDict.

Now, it turns out the OpenType Sanitizer will reject such CFF fonts with empty Blues operators in the PrivateDict:

See https://github.com/khaledhosny/ots/blob/dcfa05f/src/cff.cc#L378-L385

I am not sure whether it's OTS that is being too picky, or whether these empty deltas in PrivateDict are actually invalid in CFF.

In any case, we can work around this OTS failure by setting each of these PrivateDict blues only if they are not empty -- rather than checking if only two of them are non-empty.

The same ufo2ft behaviour of writing empty deltas was also triggering another fonttools issue (now fixed):
fonttools/fonttools#883

@anthrotype
Copy link
Member Author

/cc @miguelsousa

Cosimo Lupo added 2 commits March 9, 2017 20:14
Currently ufo2ft writes all the _four_ blue values (`BlueValues`, `OtherBlues`, `FamilyBlues`, `FamilyOtherBlues`) whenever either `postscriptBlueValues` or `postscriptOtherBlues` are non-empty lists in the UFO fontinfo.plist. It only checks those two, but then writes all four of them.

So even if the others are empty, they will still be compiled as empty deltas in the CFF PrivateDict.

Now, it turns out the OpenType Sanitizer will reject such CFF fonts with empty Blues operators in the PrivateDict:

See https://github.com/khaledhosny/ots/blob/dcfa05f/src/cff.cc#L378-L385

I am not sure whether it's OTS that is being too picky, or whether these empty deltas in PrivateDict are actually invalid in CFF.

In any case, we can work around this OTS failure by setting each of these PrivateDict blues only if they are not empty -- rather than checking if only two of them are non-empty.

The same ufo2ft behaviour of writing empty deltas was also triggering another fonttools issue (now fixed):
fonttools/fonttools#883
@miguelsousa
Copy link

I think OTS is being too picky, but I this is a good change, so 👍

@anthrotype
Copy link
Member Author

Thanks Miguel. I'm cc-ing @khaledhosny who maintains OTS to see if we could relax that check a bit.
From my reading of the CFF PrivateDict spec, those operators appear to be all optional, but also there is no mention that if they are there they must contain non-empty values.
The only mention about one of them being required is BlueValues, but that was the Type 1 spec.

@khaledhosny
Copy link
Collaborator

I think it is safer (and quicker) to just not write empty operator than for me to try to guess what the original OTS author(s) had in mind when this check was written, fix it, then wait for the new version of OTS to propagate to the browsers and for significant users to switch to new enough versions. It will probably be several years, at best, before one can rely on this anyway. :)

But feel free to open an issue against OTS so that we can look into this at some point.

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

3 participants