make decompiling charstrings work again
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@242 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
parent
4756b3a040
commit
016ca76e91
@ -1,7 +1,7 @@
|
|||||||
"""cffLib.py -- read/write tools for Adobe CFF fonts."""
|
"""cffLib.py -- read/write tools for Adobe CFF fonts."""
|
||||||
|
|
||||||
#
|
#
|
||||||
# $Id: cffLib.py,v 1.13 2002-05-16 18:17:32 jvr Exp $
|
# $Id: cffLib.py,v 1.14 2002-05-16 18:38:03 jvr Exp $
|
||||||
#
|
#
|
||||||
|
|
||||||
import struct, sstruct
|
import struct, sstruct
|
||||||
@ -32,6 +32,7 @@ class CFFFontSet:
|
|||||||
self.strings = IndexedStrings(list(Index(file)))
|
self.strings = IndexedStrings(list(Index(file)))
|
||||||
self.GlobalSubrs = SubrsIndex(file)
|
self.GlobalSubrs = SubrsIndex(file)
|
||||||
self.topDictIndex.strings = self.strings
|
self.topDictIndex.strings = self.strings
|
||||||
|
self.topDictIndex.GlobalSubrs = self.GlobalSubrs
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self.fontNames)
|
return len(self.fontNames)
|
||||||
@ -44,10 +45,7 @@ class CFFFontSet:
|
|||||||
index = self.fontNames.index(name)
|
index = self.fontNames.index(name)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise KeyError, name
|
raise KeyError, name
|
||||||
font = self.topDictIndex[index]
|
return self.topDictIndex[index]
|
||||||
if not hasattr(font, "GlobalSubrs"):
|
|
||||||
font.GlobalSubrs = self.GlobalSubrs
|
|
||||||
return font
|
|
||||||
|
|
||||||
def compile(self):
|
def compile(self):
|
||||||
strings = IndexedStrings()
|
strings = IndexedStrings()
|
||||||
@ -143,6 +141,9 @@ class CharStrings:
|
|||||||
def keys(self):
|
def keys(self):
|
||||||
return self.nameToIndex.keys()
|
return self.nameToIndex.keys()
|
||||||
|
|
||||||
|
def values(self):
|
||||||
|
return list(self.charStringsIndex)
|
||||||
|
|
||||||
def has_key(self, name):
|
def has_key(self, name):
|
||||||
return self.nameToIndex.has_key(name)
|
return self.nameToIndex.has_key(name)
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ class CharStrings:
|
|||||||
|
|
||||||
class TopDictIndex(Index):
|
class TopDictIndex(Index):
|
||||||
def produceItem(self, data, file, offset, size):
|
def produceItem(self, data, file, offset, size):
|
||||||
top = TopDict(self.strings, file, offset)
|
top = TopDict(self.strings, file, offset, self.GlobalSubrs)
|
||||||
top.decompile(data)
|
top.decompile(data)
|
||||||
return top
|
return top
|
||||||
|
|
||||||
@ -405,6 +406,10 @@ class TopDict(BaseDict):
|
|||||||
order = buildOrder(topDictOperators)
|
order = buildOrder(topDictOperators)
|
||||||
decompiler = TopDictDecompiler
|
decompiler = TopDictDecompiler
|
||||||
|
|
||||||
|
def __init__(self, strings, file, offset, GlobalSubrs):
|
||||||
|
BaseDict.__init__(self, strings, file, offset)
|
||||||
|
self.GlobalSubrs = GlobalSubrs
|
||||||
|
|
||||||
def getGlyphOrder(self):
|
def getGlyphOrder(self):
|
||||||
return self.charset
|
return self.charset
|
||||||
|
|
||||||
@ -416,6 +421,9 @@ class TopDict(BaseDict):
|
|||||||
self.file.seek(offset)
|
self.file.seek(offset)
|
||||||
self.numGlyphs, = struct.unpack(">H", self.file.read(2))
|
self.numGlyphs, = struct.unpack(">H", self.file.read(2))
|
||||||
|
|
||||||
|
def toXML(self, xmlWriter, progress):
|
||||||
|
self.decompileAllCharStrings()
|
||||||
|
BaseDict.toXML(self, xmlWriter, progress)
|
||||||
def decompileAllCharStrings(self):
|
def decompileAllCharStrings(self):
|
||||||
if self.CharstringType == 2:
|
if self.CharstringType == 2:
|
||||||
# Type 2 CharStrings
|
# Type 2 CharStrings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user