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

fixes #684 [tx] -cff2 blend/path optimization should respect stack limit #697

Merged
merged 10 commits into from
Dec 18, 2018

Conversation

blueshade7
Copy link
Contributor

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.

Copy link
Contributor

@cjchapman cjchapman left a 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 */
Copy link
Contributor

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..."?

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@cjchapman cjchapman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Copy link
Contributor

@readroberts readroberts left a 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.

@blueshade7 blueshade7 merged commit 89a0479 into develop Dec 18, 2018
@blueshade7 blueshade7 deleted the fix_csoptbug branch December 18, 2018 18:12
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.

3 participants