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

Dump contour values relative to each other instead of (0, 0) #661

Closed
RoelN opened this issue Sep 5, 2016 · 4 comments
Closed

Dump contour values relative to each other instead of (0, 0) #661

RoelN opened this issue Sep 5, 2016 · 4 comments

Comments

@RoelN
Copy link

RoelN commented Sep 5, 2016

In the spec I read about coordinates:

First coordinates relative to (0,0); others are relative to previous point.

Yet the coordinates dumped with ttx/FontTools all seem to be relative to (0, 0). Is there any way to dump/compile them relative to the previous point?

@RoelN RoelN changed the title Question about contour values Dump contour values relative to each other instead of (0, 0) Sep 5, 2016
@behdad
Copy link
Member

behdad commented Sep 5, 2016

There isn't. The compiler concerts them to absolute. We consider that a bye encoding detail. Why do you need that?

@RoelN
Copy link
Author

RoelN commented Sep 5, 2016

When coordinates are absolute you can't move a point farther than 32,767. Currently <pt x="-16383" y="16383" on="1"/> works, but <pt x="-16384" y="16384" on="1"/> crashes ttx/FontTools with the message OverflowError: signed short integer is greater than maximum. This is half the value of an unsigned int, so I didn't expect that.

With relative values I can work around this making steps of the maximum value so I end up at my ridiculous large value.

I am experimenting so I understand you probably won't need this for production stuff.

Edit: this is the full contour, which gives the overflow error. A single point with x="-16384" y="16384" works, but when this gets converted to absolute you'll overflow the SHORT:

    <pt x="-16384" y="16384" on="1"/>     <!-- Top left -->
    <pt x="16384" y="16384" on="1"/>  <!-- Top right -->
    <pt x="16384" y="-16384" on="1"/>     <!-- Bottom right -->
    <pt x="-16384" y="-16384" on="1"/>        <!-- Bottom left -->

@behdad
Copy link
Member

behdad commented Sep 8, 2016

You are misinterpreting the error. What we expose to user doesn't limit anything. You get the error because the relative step from -16384 to +16384 does not fit into a SHORT. You are free to take as many large steps as you want as long as the difference between consecutive ones does not exceed the SHORT range (-32768..+32767)

@behdad behdad closed this as completed Sep 8, 2016
@RoelN
Copy link
Author

RoelN commented Sep 9, 2016

Ah yes, check. Thanks for the explanation!

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

No branches or pull requests

2 participants