def test(): filename = sys.argv[1] data = read_type1_file(filename) data = streamfilter.StringDecode(data, None) subrs, char_strings = parse_type1_file(data) items = char_strings.items() items.sort() interpreter = CharStringInterpreter(subrs) for name, code in items: print name, ` code ` interpreter.execute(code) interpreter.print_path() interpreter.reset()
def Load(self): try: self.document() self.layer() parser = saxexts.make_parser() parser.setDocumentHandler(SVGHandler(self)) try: self.file.seek(0) file = self.file except: file = streamfilter.StringDecode(self.match.string, self.file) parser.parseFile(file) self.end_all() self.object.load_Completed() return self.object except: warn_tb('INTERNAL') raise
def read_outlines(filename): data = read_type1_file(filename) data = streamfilter.StringDecode(data, None) subrs, char_strings = parse_type1_file(data) interpreter = CharStringInterpreter(subrs) return char_strings, interpreter
def Load(self): # Begin read EPS Binary File Header header = self.match.string[0:32] if header[0] == chr(0xC5): if len(header) < 32: header += self.file.read(32 - len(header)) filetype, startPS, sizePS, startWMF, sizeWMF, \ startTIFF, sizeTIFF, Checksum = unpack(struct_eps_header, header) self.file.seek(startPS) # End read EPS Binary File Header funclist = self.get_compiled() # binding frequently used functions to local variables speeds up # the process considerably... a = apply t = tuple DSC = DSC_COMMENT MAX = MAX_DATA_TOKEN split = string.split stack = self.stack push = self.stack.append unknown_operator = (None, None) decoder = streamfilter.StringDecode(self.match.string, self.file) self.tokenizer = PSTokenizer(decoder) self.tokenizer.ai_pseudo_comments = 1 self.tokenizer.ai_dsc = 1 next = self.tokenizer.next self.document() value = self.read_prolog() while 1: token, value = next() if token <= MAX: push(value) elif token == DSC: if ':' in value: keyword, value = split(value, ':', 1) else: keyword = value if keyword in ('PageTrailer', 'Trailer'): break elif keyword == 'AI5_BeginPalette': self.skip_to_dsc('AI5_EndPalette', 'EndSetup') elif keyword == "AI8_BeginBrushPattern": self.skip_to_dsc('AI8_EndBrushPattern', 'EndSetup') elif token == END: break elif token == OPERATOR: method, argc = funclist.get(value, unknown_operator) #if method is not None: # name = method.__name__ #else: # name = `method` if method is None: del stack[:] else: try: if argc: args = t(stack[-argc:]) del stack[-argc:] a(method, args) else: method() except: warn_tb(INTERNAL, 'AILoader: error') self.end_all() self.object.load_Completed() for obj in self.guides: self.object.guide_layer.Insert(obj, None) return self.object