From 5e115c1d2a7d09ba106617dbafa7e92e8cd0bee6 Mon Sep 17 00:00:00 2001 From: Miguel Sousa Date: Wed, 22 Mar 2017 17:53:45 -0700 Subject: [PATCH] [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 --- Lib/fontTools/cffLib.py | 2 +- Lib/fontTools/misc/psCharStrings.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/cffLib.py b/Lib/fontTools/cffLib.py index 0e280e0b5..55fa266a7 100644 --- a/Lib/fontTools/cffLib.py +++ b/Lib/fontTools/cffLib.py @@ -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 diff --git a/Lib/fontTools/misc/psCharStrings.py b/Lib/fontTools/misc/psCharStrings.py index 274fe6fad..b0923c196 100644 --- a/Lib/fontTools/misc/psCharStrings.py +++ b/Lib/fontTools/misc/psCharStrings.py @@ -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:]