Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fontInstancePath)
co_args = ['-e', '-q', fontInstancePath]
if options.no_round:
co_args.insert(0, '-d')
try:
checkoutlinesUFO(co_args)
except (Exception, SystemExit):
raise
if options.doAutoHint:
logger.info("Running psautohint on %s ..." % fontInstancePath)
ah_args = ['--no-zones-stems', fontInstancePath]
if options.no_round:
ah_args.insert(0, '-d')
try:
psautohint(ah_args)
except (Exception, SystemExit):
raise
def _get_glyph_width(glyph):
hash_pen = HashPointPen(glyph)
glyph.drawPoints(hash_pen)
return getattr(glyph, 'width', 0)
def recalcHashEntry(self, glyphName, glyph):
hashBefore, historyList = self.hashMap[glyphName]
hash_pen = HashPointPen(glyph)
glyph.drawPoints(hash_pen)
hashAfter = hash_pen.getHash()
if hashAfter != hashBefore:
self.hashMap[glyphName] = [hashAfter, historyList]
self.hashMapChanged = True
def _rd_val(str_val):
"""Round and normalize a (string) GLIF value"""
return repr(norm_float(round(ast.literal_eval(str_val), 9)))
def buildGlyphHashValue(self, width, outlineXML, glyphName,
useDefaultGlyphDir, level=0):
"""
glyphData must be the official XML from a GLIF.
We skip contours with only one point.
"""
dataList = ["w%s" % norm_float(round(width, 9))]
if level > 10:
raise UFOParseError(
"In parsing component, exceeded 10 levels of reference. "
"'%s'. " % (glyphName))
# tag is optional per spec., e.g. space glyph
# does not necessarily have it.
if outlineXML is not None:
for childContour in outlineXML:
if childContour.tag == "contour":
if len(childContour) < 2:
continue
for child in childContour:
if child.tag == "point":
ptType = child.get("type")
pointType = '' if ptType is None else ptType[0]
x = self._rd_val(child.get("x"))
def convertGLIFToBez(ufoFontData, glyphName, doAll=0):
width, skip = ufoFontData.getOrSkipGlyph(glyphName, doAll)
if skip:
return None, width
glyph = ufoFontData.glyphSet[glyphName]
round_coords = not ufoFontData.allowDecimalCoords
bez = psahUFOFontData.get_glyph_bez(glyph, round_coords)
bezString = "\n".join(bez)
bezString = "\n".join(["% " + glyphName, "sc", bezString, "ed", ""])
return bezString, width