Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
info = self.ufo.info
psName = getAttrWithFallback(info, "postscriptFontName")
cff.fontNames.append(psName)
topDict = cff.topDictIndex[0]
topDict.version = "%d.%d" % (getAttrWithFallback(info, "versionMajor"), getAttrWithFallback(info, "versionMinor"))
trademark = getAttrWithFallback(info, "trademark")
if trademark:
trademark = normalizeStringForPostscript(trademark.replace("\u00A9", "Copyright"))
if trademark != self.ufo.info.trademark:
self.log.append("[Warning] The trademark was normalized for storage in the CFF table and consequently some characters were dropped: '%s'" % trademark)
if trademark is None:
trademark = ""
topDict.Notice = trademark
copyright = getAttrWithFallback(info, "copyright")
if copyright:
copyright = normalizeStringForPostscript(copyright.replace("\u00A9", "Copyright"))
if copyright != self.ufo.info.copyright:
self.log.append("[Warning] The copyright was normalized for storage in the CFF table and consequently some characters were dropped: '%s'" % copyright)
if copyright is None:
copyright = ""
topDict.Copyright = copyright
topDict.FullName = getAttrWithFallback(info, "postscriptFullName")
topDict.FamilyName = getAttrWithFallback(info, "openTypeNamePreferredFamilyName")
topDict.Weight = getAttrWithFallback(info, "postscriptWeightName")
topDict.FontName = psName
# populate various numbers
topDict.isFixedPitch = getAttrWithFallback(info, "postscriptIsFixedPitch")
topDict.ItalicAngle = getAttrWithFallback(info, "italicAngle")
underlinePosition = getAttrWithFallback(info, "postscriptUnderlinePosition")
topDict.UnderlinePosition = round(underlinePosition)
underlineThickness = getAttrWithFallback(info, "postscriptUnderlineThickness")
topDict.UnderlineThickness = round(underlineThickness)
charStrings.charStringsAreIndexed = True
topDict.charset = []
charStringsIndex = charStrings.charStringsIndex = SubrsIndex(private=private, globalSubrs=globalSubrs)
cff.topDictIndex = topDictIndex = TopDictIndex()
topDictIndex.append(topDict)
topDictIndex.strings = strings
cff.GlobalSubrs = globalSubrs
# populate naming data
info = self.ufo.info
psName = getAttrWithFallback(info, "postscriptFontName")
cff.fontNames.append(psName)
topDict = cff.topDictIndex[0]
topDict.version = "%d.%d" % (getAttrWithFallback(info, "versionMajor"), getAttrWithFallback(info, "versionMinor"))
trademark = getAttrWithFallback(info, "trademark")
if trademark:
trademark = normalizeStringForPostscript(trademark.replace("\u00A9", "Copyright"))
if trademark != self.ufo.info.trademark:
self.log.append("[Warning] The trademark was normalized for storage in the CFF table and consequently some characters were dropped: '%s'" % trademark)
if trademark is None:
trademark = ""
topDict.Notice = trademark
copyright = getAttrWithFallback(info, "copyright")
if copyright:
copyright = normalizeStringForPostscript(copyright.replace("\u00A9", "Copyright"))
if copyright != self.ufo.info.copyright:
self.log.append("[Warning] The copyright was normalized for storage in the CFF table and consequently some characters were dropped: '%s'" % copyright)
if copyright is None:
copyright = ""
topDict.Copyright = copyright
topDict.FullName = getAttrWithFallback(info, "postscriptFullName")
topDict.FamilyName = getAttrWithFallback(info, "openTypeNamePreferredFamilyName")
topDict.Weight = getAttrWithFallback(info, "postscriptWeightName")
info = self.ufo.info
psName = getAttrWithFallback(info, "postscriptFontName")
cff.fontNames.append(psName)
topDict = cff.topDictIndex[0]
topDict.version = "%d.%d" % (getAttrWithFallback(info, "versionMajor"), getAttrWithFallback(info, "versionMinor"))
trademark = getAttrWithFallback(info, "trademark")
if trademark:
trademark = normalizeStringForPostscript(trademark.replace("\u00A9", "Copyright"))
if trademark != self.ufo.info.trademark:
self.log.append("[Warning] The trademark was normalized for storage in the CFF table and consequently some characters were dropped: '%s'" % trademark)
if trademark is None:
trademark = ""
topDict.Notice = trademark
copyright = getAttrWithFallback(info, "copyright")
if copyright:
copyright = normalizeStringForPostscript(copyright.replace("\u00A9", "Copyright"))
if copyright != self.ufo.info.copyright:
self.log.append("[Warning] The copyright was normalized for storage in the CFF table and consequently some characters were dropped: '%s'" % copyright)
if copyright is None:
copyright = ""
topDict.Copyright = copyright
topDict.FullName = getAttrWithFallback(info, "postscriptFullName")
topDict.FamilyName = getAttrWithFallback(info, "openTypeNamePreferredFamilyName")
topDict.Weight = getAttrWithFallback(info, "postscriptWeightName")
topDict.FontName = psName
# populate various numbers
topDict.isFixedPitch = getAttrWithFallback(info, "postscriptIsFixedPitch")
topDict.ItalicAngle = getAttrWithFallback(info, "italicAngle")
underlinePosition = getAttrWithFallback(info, "postscriptUnderlinePosition")
topDict.UnderlinePosition = round(underlinePosition)
underlineThickness = getAttrWithFallback(info, "postscriptUnderlineThickness")
topDict.UnderlineThickness = round(underlineThickness)
charStrings.charStringsAreIndexed = True
topDict.charset = []
charStringsIndex = charStrings.charStringsIndex = SubrsIndex(private=private, globalSubrs=globalSubrs)
cff.topDictIndex = topDictIndex = TopDictIndex()
topDictIndex.append(topDict)
topDictIndex.strings = strings
cff.GlobalSubrs = globalSubrs
# populate naming data
info = self.ufo.info
psName = getAttrWithFallback(info, "postscriptFontName")
cff.fontNames.append(psName)
topDict = cff.topDictIndex[0]
topDict.version = "%d.%d" % (getAttrWithFallback(info, "versionMajor"), getAttrWithFallback(info, "versionMinor"))
trademark = getAttrWithFallback(info, "trademark")
if trademark:
trademark = normalizeStringForPostscript(trademark.replace("\u00A9", "Copyright"))
if trademark != self.ufo.info.trademark:
self.log.append("[Warning] The trademark was normalized for storage in the CFF table and consequently some characters were dropped: '%s'" % trademark)
if trademark is None:
trademark = ""
topDict.Notice = trademark
copyright = getAttrWithFallback(info, "copyright")
if copyright:
copyright = normalizeStringForPostscript(copyright.replace("\u00A9", "Copyright"))
if copyright != self.ufo.info.copyright:
self.log.append("[Warning] The copyright was normalized for storage in the CFF table and consequently some characters were dropped: '%s'" % copyright)
if copyright is None:
copyright = ""
topDict.Copyright = copyright
topDict.FullName = getAttrWithFallback(info, "postscriptFullName")
topDict.FamilyName = getAttrWithFallback(info, "openTypeNamePreferredFamilyName")
topDict.Weight = getAttrWithFallback(info, "postscriptWeightName")
13: getAttrWithFallback(font.info, "openTypeNameLicense"),
14: getAttrWithFallback(font.info, "openTypeNameLicenseURL"),
16: getAttrWithFallback(
font.info, "openTypeNamePreferredFamilyName"),
17: getAttrWithFallback(
font.info, "openTypeNamePreferredSubfamilyName"),
}
# don't add typographic names if they are the same as the legacy ones
if nameVals[1] == nameVals[16]:
del nameVals[16]
if nameVals[2] == nameVals[17]:
del nameVals[17]
# postscript font name
if nameVals[6]:
nameVals[6] = normalizeStringForPostscript(nameVals[6])
for nameId in sorted(nameVals.keys()):
nameVal = nameVals[nameId]
if not nameVal:
continue
nameVal = tounicode(nameVal, encoding='ascii')
platformId = 3
platEncId = 10 if _isNonBMP(nameVal) else 1
langId = 0x409
# Set built name record if not set yet
if name.getName(nameId, platformId, platEncId, langId):
continue
name.setName(nameVal, nameId, platformId, platEncId, langId)
"openTypeNamePreferredSubfamilyName")
if nameVals["1"] != typographicFamilyName:
nameVals["16"] = typographicFamilyName
if nameVals["2"] != typographicSubfamilyName:
nameVals["17"] = typographicSubfamilyName
self.otf["name"] = name = newTable("name")
name.names = []
for nameId in sorted(nameVals.keys()):
nameVal = nameVals[nameId]
if not nameVal:
continue
nameIdVal = int(nameId)
if nameIdVal == 6:
# postscript font name
nameVal = normalizeStringForPostscript(nameVal)
rec = NameRecord()
rec.platformID = 3
rec.platEncID = 10 if _isNonBMP(nameVal) else 1
rec.langID = 0x409
rec.nameID = nameIdVal
rec.string = nameVal.encode(rec.getEncoding())
name.names.append(rec)
11: getAttrWithFallback(font.info, "openTypeNameManufacturerURL"),
12: getAttrWithFallback(font.info, "openTypeNameDesignerURL"),
13: getAttrWithFallback(font.info, "openTypeNameLicense"),
14: getAttrWithFallback(font.info, "openTypeNameLicenseURL"),
16: preferredFamilyName,
17: preferredSubfamilyName,
}
# don't add typographic names if they are the same as the legacy ones
if nameVals[1] == nameVals[16]:
del nameVals[16]
if nameVals[2] == nameVals[17]:
del nameVals[17]
# postscript font name
if nameVals[6]:
nameVals[6] = normalizeStringForPostscript(nameVals[6])
for nameId in sorted(nameVals.keys()):
nameVal = nameVals[nameId]
if not nameVal:
continue
nameVal = tounicode(nameVal, encoding='ascii')
platformId = 3
platEncId = 10 if _isNonBMP(nameVal) else 1
langId = 0x409
# Set built name record if not set yet
if name.getName(nameId, platformId, platEncId, langId):
continue
name.setName(nameVal, nameId, platformId, platEncId, langId)