How to use the validators.anchorsValidator function in validators

To help you get started, we’ve selected a few validators examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unified-font-object / ufoLib / Lib / ufoLib / glifLib.py View on Github external
if len(children) == 1:
				child = children[0]
				if len(child) != 3:
					raise GlifLibError("The outline element is not properly structured.")
				if child[0] == "point":
					anchor = _buildAnchorFormat1(child[1])
					if anchor is not None:
						anchors.append(anchor)
						continue
			_buildOutlineContourFormat1(pen, (attrs, children))
		elif element == "component":
			_buildOutlineComponentFormat1(pen, (attrs, children))
		else:
			raise GlifLibError("Unknown element in outline element: %s" % element)
	if glyphObject is not None and anchors:
		if not anchorsValidator(anchors):
			raise GlifLibError("GLIF 1 anchors are not properly formatted.")
		_relaxedSetattr(glyphObject, "anchors", anchors)
github unified-font-object / ufoLib / Lib / ufoLib / glifLib.py View on Github external
raise GlifLibError("The lib element occurs more than once.")
			haveSeenLib = True
			_readLib(glyphObject, children)
		else:
			raise GlifLibError("Unknown element in GLIF: %s" % element)
	# set the collected unicodes
	if unicodes:
		_relaxedSetattr(glyphObject, "unicodes", unicodes)
	# set the collected guidelines
	if guidelines:
		if not guidelinesValidator(guidelines, identifiers):
			raise GlifLibError("The guidelines are improperly formatted.")
		_relaxedSetattr(glyphObject, "guidelines", guidelines)
	# set the collected anchors
	if anchors:
		if not anchorsValidator(anchors, identifiers):
			raise GlifLibError("The anchors are improperly formatted.")
		_relaxedSetattr(glyphObject, "anchors", anchors)
github unified-font-object / ufoLib / Lib / ufoLib / glifLib.py View on Github external
def _writeAnchorsFormat1(pen, anchors):
	if not anchorsValidator(anchors):
		raise GlifLibError("anchors attribute does not have the proper structure.")
	for anchor in anchors:
		attrs = []
		x = anchor["x"]
		attrs.append(("x", str(x)))
		y = anchor["y"]
		attrs.append(("y", str(y)))
		name = anchor.get("name")
		if name is not None:
			attrs.append(("name", name))
		pen.beginPath()
		pen.addPoint((x, y), segmentType="move", name=name)
		pen.endPath()
github unified-font-object / ufoLib / Lib / ufoLib / glifLib.py View on Github external
def _writeAnchors(glyphObject, writer, identifiers):
	anchors = getattr(glyphObject, "anchors", [])
	if not anchorsValidator(anchors):
		raise GlifLibError("anchors attribute does not have the proper structure.")
	for anchor in anchors:
		attrs = []
		x = anchor["x"]
		attrs.append(("x", str(x)))
		y = anchor["y"]
		attrs.append(("y", str(y)))
		name = anchor.get("name")
		if name is not None:
			attrs.append(("name", name))
		color = anchor.get("color")
		if color is not None:
			attrs.append(("color", color))
		identifier = anchor.get("identifier")
		if identifier is not None:
			if identifier in identifiers: