make decompiling charstrings work again


git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@242 4cde692c-a291-49d1-8350-778aa11640f8
diff --git a/Lib/fontTools/cffLib.py b/Lib/fontTools/cffLib.py
index 4c72438..f0a1307 100644
--- a/Lib/fontTools/cffLib.py
+++ b/Lib/fontTools/cffLib.py
@@ -1,7 +1,7 @@
 """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
@@ -32,6 +32,7 @@
 		self.strings = IndexedStrings(list(Index(file)))
 		self.GlobalSubrs = SubrsIndex(file)
 		self.topDictIndex.strings = self.strings
+		self.topDictIndex.GlobalSubrs = self.GlobalSubrs
 	
 	def __len__(self):
 		return len(self.fontNames)
@@ -44,10 +45,7 @@
 			index = self.fontNames.index(name)
 		except ValueError:
 			raise KeyError, name
-		font = self.topDictIndex[index]
-		if not hasattr(font, "GlobalSubrs"):
-			font.GlobalSubrs = self.GlobalSubrs
-		return font
+		return self.topDictIndex[index]
 	
 	def compile(self):
 		strings = IndexedStrings()
@@ -143,6 +141,9 @@
 	def keys(self):
 		return self.nameToIndex.keys()
 	
+	def values(self):
+		return list(self.charStringsIndex)
+	
 	def has_key(self, name):
 		return self.nameToIndex.has_key(name)
 	
@@ -163,7 +164,7 @@
 
 class TopDictIndex(Index):
 	def produceItem(self, data, file, offset, size):
-		top = TopDict(self.strings, file, offset)
+		top = TopDict(self.strings, file, offset, self.GlobalSubrs)
 		top.decompile(data)
 		return top
 
@@ -405,6 +406,10 @@
 	order = buildOrder(topDictOperators)
 	decompiler = TopDictDecompiler
 	
+	def __init__(self, strings, file, offset, GlobalSubrs):
+		BaseDict.__init__(self, strings, file, offset)
+		self.GlobalSubrs = GlobalSubrs
+	
 	def getGlyphOrder(self):
 		return self.charset
 	
@@ -416,6 +421,9 @@
 		self.file.seek(offset)
 		self.numGlyphs, = struct.unpack(">H", self.file.read(2))
 	
+	def toXML(self, xmlWriter, progress):
+		self.decompileAllCharStrings()
+		BaseDict.toXML(self, xmlWriter, progress)
 	def decompileAllCharStrings(self):
 		if self.CharstringType == 2:
 			# Type 2 CharStrings