Пример #1
0
 def toXML(self, writer, ttFont):
     axisTags = [axis.axisTag for axis in ttFont["fvar"].axes]
     for axis in axisTags:
         writer.begintag("segment", axis=axis)
         writer.newline()
         for key, value in sorted(self.segments[axis].items()):
             key = fl2str(key, 14)
             value = fl2str(value, 14)
             writer.simpletag("mapping", **{"from": key, "to": value})
             writer.newline()
         writer.endtag("segment")
         writer.newline()
Пример #2
0
 def toXML(self, writer, ttFont):
     name = ttFont["name"].getDebugName(self.nameIndex)
     writer.begintag("trackEntry", (('value', fl2str(self.track, 16)),
                                    ('nameIndex', self.nameIndex)))
     writer.newline()
     if name:
         writer.comment(name)
         writer.newline()
     for size, perSizeValue in sorted(self.items()):
         writer.simpletag("track",
                          size=fl2str(size, 16),
                          value=perSizeValue)
         writer.newline()
     writer.endtag("trackEntry")
     writer.newline()
Пример #3
0
 def toXML(self, writer, ttFont):
     name = ttFont["name"].getDebugName(self.subfamilyNameID)
     if name is not None:
         writer.newline()
         writer.comment(name)
         writer.newline()
     psname = ttFont["name"].getDebugName(self.postscriptNameID)
     if psname is not None:
         writer.comment(u"PostScript: " + psname)
         writer.newline()
     if self.postscriptNameID == 0xFFFF:
         writer.begintag("NamedInstance",
                         flags=("0x%X" % self.flags),
                         subfamilyNameID=self.subfamilyNameID)
     else:
         writer.begintag(
             "NamedInstance",
             flags=("0x%X" % self.flags),
             subfamilyNameID=self.subfamilyNameID,
             postscriptNameID=self.postscriptNameID,
         )
     writer.newline()
     for axis in ttFont["fvar"].axes:
         writer.simpletag("coord",
                          axis=axis.axisTag,
                          value=fl2str(self.coordinates[axis.axisTag], 16))
         writer.newline()
     writer.endtag("NamedInstance")
     writer.newline()
Пример #4
0
	def toXML(self, writer, ttFont):
		attrs = [("glyphName", self.glyphName)]
		if not hasattr(self, "firstPt"):
			attrs = attrs + [("x", self.x), ("y", self.y)]
		else:
			attrs = attrs + [("firstPt", self.firstPt), ("secondPt", self.secondPt)]

		if hasattr(self, "transform"):
			transform = self.transform
			if transform[0][1] or transform[1][0]:
				attrs = attrs + [
					("scalex", fl2str(transform[0][0], 14)),
					("scale01", fl2str(transform[0][1], 14)),
					("scale10", fl2str(transform[1][0], 14)),
					("scaley", fl2str(transform[1][1], 14)),
				]
			elif transform[0][0] != transform[1][1]:
				attrs = attrs + [
					("scalex", fl2str(transform[0][0], 14)),
					("scaley", fl2str(transform[1][1], 14)),
				]
			else:
				attrs = attrs + [("scale", fl2str(transform[0][0], 14))]
		attrs = attrs + [("flags", hex(self.flags))]
		writer.simpletag("component", attrs)
		writer.newline()
Пример #5
0
 def toXML(self, writer, axisTags):
     writer.begintag("tuple")
     writer.newline()
     for axis in axisTags:
         value = self.axes.get(axis)
         if value is not None:
             minValue, value, maxValue = value
             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
             if minValue == defaultMinValue and maxValue == defaultMaxValue:
                 writer.simpletag("coord",
                                  axis=axis,
                                  value=fl2str(value, 14))
             else:
                 attrs = [
                     ("axis", axis),
                     ("min", fl2str(minValue, 14)),
                     ("value", fl2str(value, 14)),
                     ("max", fl2str(maxValue, 14)),
                 ]
                 writer.simpletag("coord", attrs)
             writer.newline()
     wrote_any_deltas = False
     for i, delta in enumerate(self.coordinates):
         if type(delta) == tuple and len(delta) == 2:
             writer.simpletag("delta", pt=i, x=delta[0], y=delta[1])
             writer.newline()
             wrote_any_deltas = True
         elif type(delta) == int:
             writer.simpletag("delta", cvt=i, value=delta)
             writer.newline()
             wrote_any_deltas = True
         elif delta is not None:
             log.error("bad delta format")
             writer.comment("bad delta #%d" % i)
             writer.newline()
             wrote_any_deltas = True
     if not wrote_any_deltas:
         writer.comment("no deltas")
         writer.newline()
     writer.endtag("tuple")
     writer.newline()
Пример #6
0
 def toXML(self, writer, ttFont):
     name = ttFont["name"].getDebugName(self.axisNameID)
     if name is not None:
         writer.newline()
         writer.comment(name)
         writer.newline()
     writer.begintag("Axis")
     writer.newline()
     for tag, value in [("AxisTag", self.axisTag),
                        ("Flags", "0x%X" % self.flags),
                        ("MinValue", fl2str(self.minValue, 16)),
                        ("DefaultValue", fl2str(self.defaultValue, 16)),
                        ("MaxValue", fl2str(self.maxValue, 16)),
                        ("AxisNameID", str(self.axisNameID))]:
         writer.begintag(tag)
         writer.write(value)
         writer.endtag(tag)
         writer.newline()
     writer.endtag("Axis")
     writer.newline()