Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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"))