tags:

views:

84

answers:

1

I've written a few routines to parse CFF font data.

Occasionally I am getting extra items on the stack when processing an hvcurveto and vvcurveto command.

For these two commands the stack depth should be either

4, 5, 12, 13, 20, 21, ...

or

8, 9, 16, 17, 24, 25, ...

For some fonts I'm getting a stack size of 10. There's an extra parameter there for some reason.

Does this indicate I've made a mistake processing the previous commands - or are extra commands on the stack common for CFF fonts?

The curve commands are in a subroutine and the extra parameter seems to be passed into the subr.

It seems like the extra parameters are there whenever there are hint commands in the middle of the CFF stream instead of right at the beginning.

A: 

As per the CFF specs there should not be extra items on the stack - the beginning and end stack markers are clearly there for a reason.

It turns out that I was not processing the hint mask correctly and this incorrectly left the extra parameter on the stack.

Bing