def fromXML(self, name, attrs, content): from fontemon_blender_addon.fontTools.misc.textTools import binary2num, readHex if attrs.get("raw"): self.setBytecode(readHex(content)) return content = strjoin(content) content = content.split() program = [] end = len(content) i = 0 while i < end: token = content[i] i = i + 1 try: token = int(token) except ValueError: try: token = strToFixedToFloat(token, precisionBits=16) except ValueError: program.append(token) if token in ('hintmask', 'cntrmask'): mask = content[i] maskBytes = b"" for j in range(0, len(mask), 8): maskBytes = maskBytes + bytechr(binary2num(mask[j:j+8])) program.append(maskBytes) i = i + 1 else: program.append(token) else: program.append(token) self.setProgram(program)
def fromXML(self, name, attrs, content, ttFont): if name == "hexdata": self.data[attrs["tag"]] = readHex(content) elif name == "text" and attrs["tag"] in ["dlng", "slng"]: self.data[attrs["tag"]] = strjoin(content).strip() else: raise TTLibError("can't handle '%s' element" % name)
def fromXML(self, name, attrs, content, ttFont): if name == "assembly": self.fromAssembly(strjoin(content)) self._assemble() del self.assembly else: assert name == "bytecode" self.fromBytecode(readHex(content))
def fromXML(self, name, attrs, content, ttFont): if name == "GMAPs": if not hasattr(self, "GMAPs"): self.GMAPs = [] for element in content: if isinstance(element, basestring): continue itemName, itemAttrs, itemContent = element if itemName == "hexdata": self.GMAPs.append(readHex(itemContent)) elif name == "glyphlets": if not hasattr(self, "glyphlets"): self.glyphlets = [] for element in content: if isinstance(element, basestring): continue itemName, itemAttrs, itemContent = element if itemName == "hexdata": self.glyphlets.append(readHex(itemContent)) else: setattr(self, name, safeEval(attrs["value"]))
def fromXML(self, name, attrs, content, ttFont): if name == "ref": # glyph is a "dupe", i.e. a reference to another glyph's image data. # in this case imageData contains the glyph id of the reference glyph # get glyph id from glyphname self.imageData = struct.pack( ">H", ttFont.getGlyphID(safeEval("'''" + attrs["glyphname"] + "'''"))) elif name == "hexdata": self.imageData = readHex(content) else: from fontemon_blender_addon.fontTools import ttLib raise ttLib.TTLibError("can't handle '%s' element" % name)
def fromXML(self, name, attrs, content, ttFont): if name not in ("psNames", "extraNames", "hexdata"): setattr(self, name, safeEval(attrs["value"])) elif name == "psNames": self.mapping = {} for element in content: if not isinstance(element, tuple): continue name, attrs, content = element if name == "psName": self.mapping[attrs["name"]] = attrs["psName"] elif name == "extraNames": self.extraNames = [] for element in content: if not isinstance(element, tuple): continue name, attrs, content = element if name == "psName": self.extraNames.append(attrs["name"]) else: self.data = readHex(content)
def fromXML(self, name, attrs, content, ttFont): from fontemon_blender_addon.fontTools.misc.textTools import readHex from fontemon_blender_addon.fontTools import ttLib if name != "hexdata": raise ttLib.TTLibError("can't handle '%s' element" % name) self.decompile(readHex(content), ttFont)
def fromXML(self, name, attrs, content, ttFont): self.data = readHex(content) self.cmap = {}
def fromXML(self, name, attrs, content, ttFont): self.decompile(readHex(content), ttFont)
def _readRawImageData(bitmapObject, name, attrs, content, ttFont): bitmapObject.imageData = readHex(content)