More
This commit is contained in:
parent
d8d366de7e
commit
8946a5f753
@ -449,7 +449,7 @@ class GlyphSet(object):
|
|||||||
return data
|
return data
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(e, IOError) and e.errno == 2:
|
if isinstance(e, IOError) and e.errno == 2:
|
||||||
raise MissingPlistError()
|
raise MissingPlistError(path)
|
||||||
raise GlifLibError("The file %s could not be read." % path)
|
raise GlifLibError("The file %s could not be read." % path)
|
||||||
|
|
||||||
|
|
||||||
@ -1085,7 +1085,7 @@ def _buildOutlineComponentFormat1(pen, component):
|
|||||||
raise GlifLibError("Unknown child elements of component element.")
|
raise GlifLibError("Unknown child elements of component element.")
|
||||||
for attr in component.attrib.keys():
|
for attr in component.attrib.keys():
|
||||||
if attr not in componentAttributesFormat1:
|
if attr not in componentAttributesFormat1:
|
||||||
raise GlifLibError("Unknown attributes in component element.")
|
raise GlifLibError("Unknown attribute in component element: %s" % attr)
|
||||||
baseGlyphName = component.get("base")
|
baseGlyphName = component.get("base")
|
||||||
if baseGlyphName is None:
|
if baseGlyphName is None:
|
||||||
raise GlifLibError("The base attribute is not defined in the component.")
|
raise GlifLibError("The base attribute is not defined in the component.")
|
||||||
@ -1111,8 +1111,9 @@ def buildOutlineFormat2(glyphObject, pen, outline, identifiers):
|
|||||||
raise GlifLibError("Unknown element in outline element: %s" % element.tag)
|
raise GlifLibError("Unknown element in outline element: %s" % element.tag)
|
||||||
|
|
||||||
def _buildOutlineContourFormat2(pen, contour, identifiers):
|
def _buildOutlineContourFormat2(pen, contour, identifiers):
|
||||||
if set(contour.attrib.keys()) - contourAttributesFormat2:
|
for attr in contour.attrib.keys():
|
||||||
raise GlifLibError("Unknown attributes in contour element.")
|
if attr not in contourAttributesFormat2:
|
||||||
|
raise GlifLibError("Unknown attribute in contour element: %s" % attr)
|
||||||
identifier = contour.get("identifier")
|
identifier = contour.get("identifier")
|
||||||
if identifier is not None:
|
if identifier is not None:
|
||||||
if identifier in identifiers:
|
if identifier in identifiers:
|
||||||
@ -1155,7 +1156,7 @@ def _buildOutlineComponentFormat2(pen, component, identifiers):
|
|||||||
raise GlifLibError("Unknown child elements of component element.")
|
raise GlifLibError("Unknown child elements of component element.")
|
||||||
for attr in component.attrib.keys():
|
for attr in component.attrib.keys():
|
||||||
if attr not in componentAttributesFormat2:
|
if attr not in componentAttributesFormat2:
|
||||||
raise GlifLibError("Unknown attributes in component element.")
|
raise GlifLibError("Unknown attribute in component element: %s" % attr)
|
||||||
baseGlyphName = component.get("base")
|
baseGlyphName = component.get("base")
|
||||||
if baseGlyphName is None:
|
if baseGlyphName is None:
|
||||||
raise GlifLibError("The base attribute is not defined in the component.")
|
raise GlifLibError("The base attribute is not defined in the component.")
|
||||||
@ -1205,14 +1206,7 @@ def _validateAndMassagePointStructures(contour, pointAttributes, openContourOffC
|
|||||||
value = element.get(attr)
|
value = element.get(attr)
|
||||||
if value is None:
|
if value is None:
|
||||||
raise GlifLibError("Required %s attribute is missing in point element." % attr)
|
raise GlifLibError("Required %s attribute is missing in point element." % attr)
|
||||||
try:
|
element.attrib[attr] = _number(value)
|
||||||
value = int(value)
|
|
||||||
except ValueError:
|
|
||||||
try:
|
|
||||||
value = float(value)
|
|
||||||
except ValueError:
|
|
||||||
raise GlifLibError("Invalid %s value in point element: %s" % (attr, value))
|
|
||||||
element.attrib[attr] = value
|
|
||||||
# segment type
|
# segment type
|
||||||
pointType = element.attrib.pop("type", "offcurve")
|
pointType = element.attrib.pop("type", "offcurve")
|
||||||
if pointType not in pointTypeOptions:
|
if pointType not in pointTypeOptions:
|
||||||
|
@ -54,19 +54,6 @@ def genericIntListValidator(values, validValues):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def genericIntSetValidator(values, validValues):
|
|
||||||
"""
|
|
||||||
Generic. (Added at version 3.)
|
|
||||||
"""
|
|
||||||
if not isinstance(values, (list, tuple)):
|
|
||||||
return False
|
|
||||||
for value in values:
|
|
||||||
if value not in validValues:
|
|
||||||
return False
|
|
||||||
if not isinstance(value, int):
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def genericNonNegativeIntValidator(value):
|
def genericNonNegativeIntValidator(value):
|
||||||
"""
|
"""
|
||||||
Generic. (Added at version 3.)
|
Generic. (Added at version 3.)
|
||||||
@ -134,7 +121,7 @@ def fontInfoOpenTypeGaspRangeRecordsValidator(value):
|
|||||||
return False
|
return False
|
||||||
if len(value) == 0:
|
if len(value) == 0:
|
||||||
return True
|
return True
|
||||||
validBehaviors = {0, 1, 2, 3}
|
validBehaviors = [0, 1, 2, 3]
|
||||||
dictPrototype = dict(rangeMaxPPEM=(int, True), rangeGaspBehavior=(list, True))
|
dictPrototype = dict(rangeMaxPPEM=(int, True), rangeGaspBehavior=(list, True))
|
||||||
ppemOrder = []
|
ppemOrder = []
|
||||||
for rangeRecord in value:
|
for rangeRecord in value:
|
||||||
@ -145,7 +132,7 @@ def fontInfoOpenTypeGaspRangeRecordsValidator(value):
|
|||||||
ppemValidity = genericNonNegativeIntValidator(ppem)
|
ppemValidity = genericNonNegativeIntValidator(ppem)
|
||||||
if not ppemValidity:
|
if not ppemValidity:
|
||||||
return False
|
return False
|
||||||
behaviorValidity = genericIntSetValidator(behavior, validBehaviors)
|
behaviorValidity = genericIntListValidator(behavior, validBehaviors)
|
||||||
if not behaviorValidity:
|
if not behaviorValidity:
|
||||||
return False
|
return False
|
||||||
ppemOrder.append(ppem)
|
ppemOrder.append(ppem)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user