Example #1
0
	def callback_strokepaths(self):
		if not self.groups.has_key("StrokePaths"):
			print "Error - no StrokePaths group for kanji %s (%s)" % (self.kanji, hex(kanjivg.realord(self.kanji)))
			return ""
		paths = self.groups["StrokePaths"]
		elts = paths.findall(".//{http://www.w3.org/2000/svg}path")
		strs = []
		for elt in elts:
			d = elt.attrib["d"]
			d = re.sub('(\d) (\d)', '\\1,\\2', d)
			d = re.sub("[\n\t ]+", "", d)
			strs.append('<path d="%s"/>' % (d,))
		return "\n\t\t".join(strs)
Example #2
0
	def callback_strokenumbers(self):
		if not self.groups.has_key("StrokeNumbers"):
			print "Error - no StrokeNumbers group for kanji %s (%s)" % (self.kanji, hex(kanjivg.realord(self.kanji)))
			return ""
		numbers = self.groups["StrokeNumbers"]
		elts = numbers.findall(".//{http://www.w3.org/2000/svg}text")
		strs = []
		for elt in elts:
			attrs = []
			if elt.attrib.has_key("transform"): attrs.append(' transform="%s"' % (elt.attrib["transform"],))
			if elt.attrib.has_key("x"): attrs.append(' x="%s"' % (elt.attrib["x"],))
			if elt.attrib.has_key("y"): attrs.append(' y="%s"' % (elt.attrib["y"],))
			strs.append('<text%s>%s</text>' % (''.join(attrs), findText(elt)))
		return "\n\t\t".join(strs)