Exemplo n.º 1
0
 def handle_resource_file(self, path):
     prefs = getprefs()
     dstfolder = prefs.get("xmloutput", DEFAULTXMLOUTPUT)
     if not os.path.exists(dstfolder):
         os.mkdir(dstfolder)
     filename = os.path.basename(path)
     fss = macfs.FSSpec(path)
     try:
         resref = Res.FSpOpenResFile(fss, 1)  # read-only
     except:
         return "unknown"
     Res.UseResFile(resref)
     pb = None
     try:
         n = Res.Count1Resources("sfnt")
         for i in range(1, n + 1):
             res = Res.Get1IndResource('sfnt', i)
             resid, restype, resname = res.GetResInfo()
             if not resname:
                 resname = filename + ` i `
             pb = ProgressBar("Dumping '%s' to XML..." % resname)
             dst = os.path.join(dstfolder, resname + ".ttx")
             try:
                 tt = ttLib.TTFont(path, i)
                 tt.saveXML(dst, pb)
             finally:
                 pb.close()
     finally:
         Res.CloseResFile(resref)
Exemplo n.º 2
0
	def handle_resource_file(self, path):
		prefs = getprefs()
		dstfolder = prefs.get("xmloutput", DEFAULTXMLOUTPUT)
		if not os.path.exists(dstfolder):
			os.mkdir(dstfolder)
		filename = os.path.basename(path)
		fss = macfs.FSSpec(path)
		try:
			resref = Res.FSpOpenResFile(fss, 1)  # read-only
		except:
			return "unknown"
		Res.UseResFile(resref)
		pb = None
		try:
			n = Res.Count1Resources("sfnt")
			for i in range(1, n+1):
				res = Res.Get1IndResource('sfnt', i)
				resid, restype, resname = res.GetResInfo()
				if not resname:
					resname = filename + `i`
				pb = ProgressBar("Dumping '%s' to XML..." % resname)
				dst = os.path.join(dstfolder, resname + ".ttx")
				try:
					tt = ttLib.TTFont(path, i)
					tt.saveXML(dst, pb)
				finally:
					pb.close()
		finally:
			Res.CloseResFile(resref)
Exemplo n.º 3
0
 def handle_datafork_file(self, path):
     prefs = getprefs()
     dstfolder = prefs.get("xmloutput", DEFAULTXMLOUTPUT)
     if not os.path.exists(dstfolder):
         os.mkdir(dstfolder)
     filename = os.path.basename(path)
     pb = ProgressBar("Dumping '%s' to XML..." % filename)
     if filename[-4:] in (".TTF", ".ttf"):
         filename = filename[:-4]
     filename = filename + ".ttx"
     dst = os.path.join(dstfolder, filename)
     try:
         tt = ttLib.TTFont(path)
         tt.saveXML(dst, pb)
     finally:
         pb.close()
Exemplo n.º 4
0
	def handle_datafork_file(self, path):
		prefs = getprefs()
		dstfolder = prefs.get("xmloutput", DEFAULTXMLOUTPUT)
		if not os.path.exists(dstfolder):
			os.mkdir(dstfolder)
		filename = os.path.basename(path)
		pb = ProgressBar("Dumping '%s' to XML..." % filename)
		if filename[-4:] in (".TTF", ".ttf"):
			filename = filename[:-4]
		filename = filename + ".ttx"
		dst = os.path.join(dstfolder, filename)
		try:
			tt = ttLib.TTFont(path)
			tt.saveXML(dst, pb)
		finally:
			pb.close()
Exemplo n.º 5
0
                if why[0] <> -43:  # file not found
                    EasyDialogs.Message(
                        "Can't create '%s'; file already open" % dst)
                    return
            else:
                Res.CloseResFile(testref)
        else:
            try:
                f = open(dst, "wb")
            except IOError, why:
                EasyDialogs.Message("Can't create '%s'; file already open" %
                                    dst)
                return
            else:
                f.close()
        pb = ProgressBar("Reading TTX file '%s'..." % srcfilename)
        try:
            tt = ttLib.TTFont()
            tt.importXML(path, pb)
            pb.setlabel("Compiling and saving...")
            tt.save(dst, makesuitcase)
        finally:
            pb.close()

    def handle_datafork_file(self, path):
        prefs = getprefs()
        dstfolder = prefs.get("xmloutput", DEFAULTXMLOUTPUT)
        if not os.path.exists(dstfolder):
            os.mkdir(dstfolder)
        filename = os.path.basename(path)
        pb = ProgressBar("Dumping '%s' to XML..." % filename)
Exemplo n.º 6
0
				testref = Res.FSpOpenResFile(macfs.FSSpec(dst), 3)  # read-write
			except Res.Error, why:
				if why[0] <> -43: # file not found
					EasyDialogs.Message("Can't create '%s'; file already open" % dst)
					return
			else:
				Res.CloseResFile(testref)
		else:
			try:
				f = open(dst, "wb")
			except IOError, why:
				EasyDialogs.Message("Can't create '%s'; file already open" % dst)
				return
			else:
				f.close()
		pb = ProgressBar("Reading TTX file '%s'..." % srcfilename)
		try:
			tt = ttLib.TTFont()
			tt.importXML(path, pb)
			pb.setlabel("Compiling and saving...")
			tt.save(dst, makesuitcase)
		finally:
			pb.close()
	
	def handle_datafork_file(self, path):
		prefs = getprefs()
		dstfolder = prefs.get("xmloutput", DEFAULTXMLOUTPUT)
		if not os.path.exists(dstfolder):
			os.mkdir(dstfolder)
		filename = os.path.basename(path)
		pb = ProgressBar("Dumping '%s' to XML..." % filename)