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

SAME_OR_POSITIVE ambiguity #765

Closed
simoncozens opened this issue Apr 19, 2021 · 3 comments
Closed

SAME_OR_POSITIVE ambiguity #765

simoncozens opened this issue Apr 19, 2021 · 3 comments
Assignees
Milestone

Comments

@simoncozens
Copy link

Consider these two simple glyph flag bits:

Mask Name Description
0x02 X_SHORT_VECTOR Bit 1: If set, the corresponding x-coordinate is 1 byte long. If not set, it is two bytes long. For the sign of this value, see the description of the X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR flag.
0x10 X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR Bit 4: This flag has two meanings, depending on how the X_SHORT_VECTOR flag is set. If X_SHORT_VECTOR is set, this bit describes the sign of the value, with 1 equalling positive and 0 negative. If X_SHORT_VECTOR is not set and this bit is set, then the current x-coordinate is the same as the previous x-coordinate. If X_SHORT_VECTOR is not set and this bit is also not set, the current x-coordinate is a signed 16-bit delta vector.

If X_SHORT_VECTOR is not set, and X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR is set, how many bytes should be read from the xCoordinates array?

  • One interpretation: X_SHORT_VECTOR is not set, so "the corresponding x-coordinate... is two bytes long".
  • Another interpretation: X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR is set, so "the current x-coordinate is the same as the previous x-coordinate". Therefore, no bytes need to be read.

Apparently the correct answer is that no bytes should be read. The problem is that "the corresponding x-coordinate is two bytes long" is explicitly stated in the text, and "no bytes should be read" is not explicitly stated in the text (the fact that the current x-coordinate is the same is the previous does not imply anything about storage), so a correct implementation should discard the explicit meaning of the specification in preference for the implicit meaning.

Please make the correct interpretation "no bytes should be read" more explicit.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@PeterCon PeterCon self-assigned this Jun 1, 2021
@PeterCon
Copy link
Collaborator

You're correct: in the case X_SHORT_VECTOR is not set and X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR is set, then no bytes are read. This should be clarified.

@PeterCon PeterCon added this to the OpenType 1.9 milestone Oct 20, 2021
@PeterCon
Copy link
Collaborator

PeterCon commented Oct 20, 2021

Proposed revised description for X_SHORT_VECTOR flag:

Bit 1: If set, the corresponding x-coordinate is 1 byte long, and the sign is determined by the X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR flag. If not set, its interpretation depends on the X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR flag: If that other flag is set, the x-coordinate is the same as the previous x-coordinate, and no element is added to the xCoordinates array. If both flags are not set, the corresponding element in the xCoordinates array is two bytes and interpreted as a signed integer. See the description of the X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR flag for additional information.

Analogous wording will be used for Y_SHORT_VECTOR.

@PeterCon
Copy link
Collaborator

PeterCon commented Dec 9, 2021

Addressed in OpenType 1.9. Closing.

@PeterCon PeterCon closed this as completed Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants