Exemplo n.º 1
0
 def fromXML(self, name, attrs, content, ttFont):
     self.track = str2fl(attrs['value'], 16)
     self.nameIndex = safeEval(attrs['nameIndex'])
     for element in content:
         if not isinstance(element, tuple):
             continue
         name, attrs, _ = element
         if name != 'track':
             continue
         size = str2fl(attrs['size'], 16)
         self[size] = safeEval(attrs['value'])
Exemplo n.º 2
0
 def fromXML(self, name, attrs, content, ttFont):
     if name == "segment":
         axis = attrs["axis"]
         segment = self.segments[axis] = {}
         for element in content:
             if isinstance(element, tuple):
                 elementName, elementAttrs, _ = element
                 if elementName == "mapping":
                     fromValue = str2fl(elementAttrs["from"], 14)
                     toValue = str2fl(elementAttrs["to"], 14)
                     if fromValue in segment:
                         log.warning("duplicate entry for %s in axis '%s'",
                                     fromValue, axis)
                     segment[fromValue] = toValue
Exemplo n.º 3
0
 def fromXML(self, name, attrs, _content):
     if name == "coord":
         axis = attrs["axis"]
         value = str2fl(attrs["value"], 14)
         defaultMinValue = min(value, 0.0)  # -0.3 --> -0.3; 0.7 --> 0.0
         defaultMaxValue = max(value, 0.0)  # -0.3 -->  0.0; 0.7 --> 0.7
         minValue = str2fl(attrs.get("min", defaultMinValue), 14)
         maxValue = str2fl(attrs.get("max", defaultMaxValue), 14)
         self.axes[axis] = (minValue, value, maxValue)
     elif name == "delta":
         if "pt" in attrs:
             point = safeEval(attrs["pt"])
             x = safeEval(attrs["x"])
             y = safeEval(attrs["y"])
             self.coordinates[point] = (x, y)
         elif "cvt" in attrs:
             cvt = safeEval(attrs["cvt"])
             value = safeEval(attrs["value"])
             self.coordinates[cvt] = value
         else:
             log.warning("bad delta format: %s" %
                         ", ".join(sorted(attrs.keys())))
Exemplo n.º 4
0
    def fromXML(self, name, attrs, content, ttFont):
        assert (name == "NamedInstance")
        self.subfamilyNameID = safeEval(attrs["subfamilyNameID"])
        self.flags = safeEval(attrs.get("flags", "0"))
        if "postscriptNameID" in attrs:
            self.postscriptNameID = safeEval(attrs["postscriptNameID"])
        else:
            self.postscriptNameID = 0xFFFF

        for tag, elementAttrs, _ in filter(lambda t: type(t) is tuple,
                                           content):
            if tag == "coord":
                value = str2fl(elementAttrs["value"], 16)
                self.coordinates[elementAttrs["axis"]] = value
Exemplo n.º 5
0
 def fromXML(self, name, _attrs, content, ttFont):
     assert (name == "Axis")
     for tag, _, value in filter(lambda t: type(t) is tuple, content):
         value = ''.join(value)
         if tag == "AxisTag":
             self.axisTag = Tag(value)
         elif tag in {
                 "Flags", "MinValue", "DefaultValue", "MaxValue",
                 "AxisNameID"
         }:
             setattr(
                 self, tag[0].lower() + tag[1:],
                 str2fl(value, 16)
                 if tag.endswith("Value") else safeEval(value))
Exemplo n.º 6
0
	def fromXML(self, name, attrs, content, ttFont):
		self.glyphName = attrs["glyphName"]
		if "firstPt" in attrs:
			self.firstPt = safeEval(attrs["firstPt"])
			self.secondPt = safeEval(attrs["secondPt"])
		else:
			self.x = safeEval(attrs["x"])
			self.y = safeEval(attrs["y"])
		if "scale01" in attrs:
			scalex = str2fl(attrs["scalex"], 14)
			scale01 = str2fl(attrs["scale01"], 14)
			scale10 = str2fl(attrs["scale10"], 14)
			scaley = str2fl(attrs["scaley"], 14)
			self.transform = [[scalex, scale01], [scale10, scaley]]
		elif "scalex" in attrs:
			scalex = str2fl(attrs["scalex"], 14)
			scaley = str2fl(attrs["scaley"], 14)
			self.transform = [[scalex, 0], [0, scaley]]
		elif "scale" in attrs:
			scale = str2fl(attrs["scale"], 14)
			self.transform = [[scale, 0], [0, scale]]
		self.flags = safeEval(attrs["flags"])