def extractTTFFontInfo(font): # UFO.info attribute name / index. # name table entries index according to http://www.microsoft.com/typography/otspec/name.htm attrs = [ ('copyright', 0), ('familyName', 1), ('fontStyle', 1), ('postscriptFullName', 4), ('trademark', 7), ('openTypeNameDesigner', 9), ('openTypeNameLicenseURL', 14), ('openTypeNameDesignerURL', 12), ] info = RInfo() names = font['name'] info.ascender = font['hhea'].ascent info.descender = font['hhea'].descent info.unitsPerEm = font['head'].unitsPerEm for name, index in attrs: entry = font["name"].getName(index, 3, 1) if entry is not None: try: setattr(info, name, unicode(entry.string, "utf16")) except: print "Error importing value %s: %s"%(str(name), str(info)) return info
def extractTTFFontInfo(font): # UFO.info attribute name / index. # name table entries index according to http://www.microsoft.com/typography/otspec/name.htm attrs = [ ('copyright', 0), ('familyName', 1), ('styleMapStyleName', 2), ('postscriptFullName', 4), ('trademark', 7), ('openTypeNameDesigner', 9), ('openTypeNameLicenseURL', 14), ('openTypeNameDesignerURL', 12), ] info = RInfo() names = font['name'] info.ascender = font['hhea'].ascent info.descender = font['hhea'].descent info.unitsPerEm = font['head'].unitsPerEm for name, index in attrs: entry = font["name"].getName(index, 3, 1, 0x409) if entry is not None: try: value = unicode(entry.string, "utf_16_be") if name == "styleMapStyleName": value = value.lower() setattr(info, name, value) except Exception, e: print "Error importing value %s: %s: %s" % (str(name), value, e.message)
def extractTTFFontInfo(font): # UFO.info attribute name / index. # name table entries index according to http://www.microsoft.com/typography/otspec/name.htm attrs = [ ('copyright', 0), ('familyName', 1), ('styleMapStyleName', 2), ('postscriptFullName', 4), ('trademark', 7), ('openTypeNameDesigner', 9), ('openTypeNameLicenseURL', 14), ('openTypeNameDesignerURL', 12), ] info = RInfo() names = font['name'] info.ascender = font['hhea'].ascent info.descender = font['hhea'].descent info.unitsPerEm = font['head'].unitsPerEm for name, index in attrs: entry = font["name"].getName(index, 3, 1, 0x409) if entry is not None: try: value = unicode(entry.string, "utf_16_be") if name == "styleMapStyleName": value = value.lower() setattr(info, name, value) except Exception, e: print "Error importing value %s: %s: %s"%(str(name), value, e.message)
def extractTTFFontInfo(font): # UFO.info attribute name / index. # name table entries index according to http://www.microsoft.com/typography/otspec/name.htm attrs = [ ('copyright', 0), ('familyName', 1), ('fontStyle', 1), ('postscriptFullName', 4), ('trademark', 7), ('openTypeNameDesigner', 9), ('openTypeNameLicenseURL', 14), ('openTypeNameDesignerURL', 12), ] info = RInfo() names = font['name'] info.ascender = font['hhea'].ascent info.descender = font['hhea'].descent info.unitsPerEm = font['head'].unitsPerEm for name, index in attrs: entry = font["name"].getName(index, 3, 1) if entry is not None: try: setattr(info, name, unicode(entry.string, "utf16")) except: print "Error importing value %s: %s" % (str(name), str(info)) return info
def extractT1FontInfo(font): info = RInfo() src = font.font['FontInfo'] factor = font.font['FontMatrix'][0] assert factor > 0 info.unitsPerEm = int(round(1/factor, 0)) # assume something for ascender descender info.ascender = (info.unitsPerEm / 5) * 4 info.descender = info.ascender - info.unitsPerEm info.versionMajor = font.font['FontInfo']['version'] info.fullName = font.font['FontInfo']['FullName'] info.familyName = font.font['FontInfo']['FullName'].split("-")[0] info.notice = unicode(font.font['FontInfo']['Notice'], "macroman") info.italicAngle = font.font['FontInfo']['ItalicAngle'] info.uniqueID = font['UniqueID'] return info
def extractT1FontInfo(font): info = RInfo() src = font.font['FontInfo'] factor = font.font['FontMatrix'][0] assert factor > 0 info.unitsPerEm = int(round(1 / factor, 0)) # assume something for ascender descender info.ascender = (info.unitsPerEm / 5) * 4 info.descender = info.ascender - info.unitsPerEm info.versionMajor = font.font['FontInfo']['version'] info.fullName = font.font['FontInfo']['FullName'] info.familyName = font.font['FontInfo']['FullName'].split("-")[0] info.notice = unicode(font.font['FontInfo']['Notice'], "macroman") info.italicAngle = font.font['FontInfo']['ItalicAngle'] info.uniqueID = font['UniqueID'] return info