Example #1
0
def read_metric(ps_name):
	for afm in ps_to_filename[ps_name]:
		afm = afm + '.afm'
		filename = find_in_path(config.font_path, afm)
		if filename:
			if __debug__:
				import time
				start = time.clock()
			metric = read_afm_file(filename)
			if __debug__:
				pdebug('timing', 'time to read afm %s: %g', afm,
						time.clock() - start)
			return metric
	else:
		if not _warned_about_afm.get(afm):
			warn(USER,
					_("I cannot find the metrics for the font %(ps_name)s.\n"
					"The file %(afm)s is not in the font_path.\n"
					"I'll use the metrics for %(fallback)s instead."),
					ps_name = ps_name, afm = afm,
					fallback = config.preferences.fallback_font)
			_warned_about_afm[afm] = 1
		if ps_name != config.preferences.fallback_font:
			return read_metric(config.preferences.fallback_font)
		else:
			raise SketchError("Can't load metrics for fallback font %s",
								config.preferences.fallback_font)
Example #2
0
	def SaveToFile(self, file, *args, **kw):
		if self.class_name:
			apply(file.BeginPluginCompound, (self.class_name,) + args, kw)
			for obj in self.objects:
				obj.SaveToFile(file)
			file.EndPluginCompound()
		else:
			raise SketchError("Plugin %s doesn't define a class name"
								% self.__class__)
Example #3
0
 def init_gc(self):
     self.gc = self.tkwin.GetGC()
     self.visual = color.skvisual
     w = self.tkwin
     width, height = self.image.size
     depth = self.visual.depth
     if depth > 16:
         bpl = 4 * width
     elif depth > 8:
         bpl = ((2 * width + 3) / 4) * 4
     elif depth == 8:
         bpl = ((width + 3) / 4) * 4
     else:
         raise SketchError('unsupported depth for images')
     self.ximage = w.CreateImage(depth, ZPixmap, 0, None, width, height, 32,
                                 bpl)
     self.set_image(self.image)
 def DuplicateObjects(self, infolist, offset):
     raise SketchError('Cannot duplicate objects in compound')
 def MoveObjectsToTop(self, infolist):
     raise SketchError('Cannot rearrange objects in compound')
 def Remove(self, *args, **kw):
     raise SketchError('Cannot remove from compound')
 def Insert(self, obj, at):
     raise SketchError('Cannot insert in compound')