def __init__(self, name, sizes=defaultSizes): filename = Util.dataFile(name) pygame.font.init() self.sizes = {} self.sortedSizes = sizes self.sortedSizes.sort() for size in sizes: self.sizes[size] = RenderedFont(filename, size)
def loadDataFile(self, name): """Load the texture from a file in our data directory. The main reason for this function to exist is so a texture can be pickled without hardcoding the data path in the pickle. """ self.loadImage(Image.open(Util.dataFile(name))) self.loader = ('loadDataFile', name) self.name = name
parser = optik.OptionParser(usage = "usage: %prog [options] worlds") parser.add_option("-o", "--output", metavar="FILE", help="Sets the file or directory name to output thumbnails to.") parser.add_option("-s", "--size", metavar="WIDTHxHEIGHT", help="Sets the thumbnail size. Default is 160x160.", default="160x160") parser.add_option("-i", "--index", action="store_true", help="Generates an index of world files to the directory provided with -o.") parser.add_option("-f", "--format", metavar="EXTENSION", help="Sets the format, specified in the form of a file extension name, " + "of the images to generate when an explicit filename is not given. Default is 'png'.", default='png') parser.add_option("-a", "--oversample", metavar="AMOUNT", help="Sets the amount of oversampling. Higher numbers will produce smoother images " + "with thinner borders, but will require much more memory and CPU time. Default is 3.", default=3) parser.add_option("-t", "--template", metavar="FILE", help="Sets the template file to use for producing index output. Default is " + "'worldindex.html' in the data directory.", default=Util.dataFile('worldindex.html')) parser.add_option("-n", "--index-name", metavar="FILE", dest="indexName", help="Sets the name of the index file to produce in the output directory. Default is 'index.html'.", default="index.html") (options, args) = parser.parse_args() if len(args) == 0: parser.error("One or more world filenames must be specified on the command line.") if len(args) > 1 and options.output and not os.path.isdir(options.output): parser.error("An output directory must be specified for multiple input files, not an output file.") if options.index and options.output and not os.path.isdir(options.output): parser.error("An output directory must be specified for indexing mode, not an output file.") size = map(int, options.size.split("x")) oversample = int(options.oversample) worlds = []
def load(name): from BZFlag import Util return defaultCache.load(Util.dataFile(name))