-
Notifications
You must be signed in to change notification settings - Fork 168
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
fixes #684 [tx] -cff2 blend/path optimization should respect stack limit #697
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good overall, I just have a couple of minor concerns I'd like addressed.
cstr_saveop(h, op); | ||
|
||
h->pendop = tx_noop; /* Clear pending op */ | ||
} | ||
|
||
/* Returns 1 if argcnt maybe blended args may overflow the operand stack */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not clear to me. Did you mean "...argcnt plus blended args will overflow..."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct
@@ -484,11 +505,18 @@ static void pushBlendDeltas(cstrCtx h, abfBlendArg *blendArg) { | |||
|
|||
static void flushBlends(cstrCtx h) { | |||
int i; | |||
if ((h->deltaStack.cnt + h->stack.cnt) > 513) { | |||
if ((h->deltaStack.cnt + 1 + h->stack.cnt + h->flushed_cnt | |||
+ ((h->g->flags & CFW_SUBRIZE) ? 1 : 0)) > CFF2_MAX_OP_STACK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use checkOverflow(h)
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because checkOverflow()
is used to check against overflow before pushing numRegions+1 of arguments onto stack. The condition here is to detect if overflow actually happened, and it shouldn't happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I have no additional changes to suggest.
Fixes tx issue #684 [tx] -cff2 blend/path optimization should respect stack limit
The charstring optimization enabled by default (disabled with -no_opt) is supposed to generate charstrings that would not overflow the standard operand stack size (48 for CFF1, 513 for CFF2), but the limit check was not correctly calculated with CFF2 variable font blending charstrings.
Also added a test case that used to break the limit, and is now fixed along with its expected result.