[CFF2] Report the correct number of regions in the font

This change also makes the processing of the blend operator to be as described at https://www.microsoft.com/typography/otspec/cff2charstr.htm#section4.5
This commit is contained in:
Miguel Sousa 2017-03-22 17:53:45 -07:00
parent 6ac3523d74
commit 5e115c1d2a
2 changed files with 3 additions and 3 deletions

View File

@ -779,7 +779,7 @@ class VarStoreData(object):
def getNumRegions(self, vsIndex):
varData = self.otVarStore.VarData[vsIndex]
numRegions = varData.VarRegionCount +1 # The VarData VarRegionCount does not include the defautl region; the blend arg list does.
numRegions = varData.VarRegionCount
return numRegions

View File

@ -436,7 +436,7 @@ class SimpleCFF2Decompiler(SimpleT2Decompiler):
if self.numRegions == 0:
self.numRegions = self.private.getNumRegions()
numBlends = self.pop()
numOps = numBlends*self.numRegions
numOps = numBlends * (self.numRegions + 1)
blendArgs = self.operandStack[-numOps:]
del self.operandStack[:-(numOps-numBlends)] # Leave the default operands on the stack.
@ -1291,7 +1291,7 @@ class DictDecompiler(ByteCodeBase):
# Total number of values is numValues + (numValues * (numMasters -1)), == numValues * numMasters.
# reformat list to be numReturnValues tuples, each tuple with nMaster values
vsindex = self.dict.get('vsindex', 0)
numMasters = self.parent.getNumRegions(vsindex) # only a PrivateDict has blended ops.
numMasters = self.parent.getNumRegions(vsindex) + 1 # only a PrivateDict has blended ops.
numReturnValues = self.pop()
stackIndex = -numMasters * numReturnValues
args = self.stack[stackIndex:]