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

compileOTF produces Type2 CharString that exceeds the stack size limit #266

Closed
irori opened this issue Jul 23, 2018 · 1 comment
Closed

Comments

@irori
Copy link

irori commented Jul 23, 2018

(Filing here because I'm not sure which dependent library should be fixed.)

This program generates a font which reproduces the problem:
https://gist.github.com/irori/b0d5f53b6298efab4e526d68be2eab8d

Generated font is rejected by OTS because its Type2 Charstring exceeds the argument stack depth limit (48).

The above test program produces Type2 Charstrings like this:

[push 2 numbers] RMoveTo
[push 48 numbers] RLineTo
-90 -100 RMoveTo
10 10 10 10 10 10 10 10 10 VLineTo
EndChar

After RLineTo are common to all glyphs, so compreffor subroutinizes it, resulting in:

[push 2 numbers] RMoveTo
[push 48 numbers] [push 1 number] CallSubr

This exceeds the stack size limit.

Possible fixes:

@behdad
Copy link
Collaborator

behdad commented Jul 25, 2018

Reduce maxstack for fontTools.cffLib.specializer.specializeCommands by 1, so that there's always a room for a subroutine number.

This makes sense to me.

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