WOFF copyright.

git-svn-id: http://svn.robofab.com/branches/ufo3k@281 b5fa9d6c-a76f-4ffd-b3cb-f825fc41095c
This commit is contained in:
Tal Leming 2011-09-16 16:34:32 +00:00
parent 061df1317e
commit bdfc82582d
3 changed files with 129 additions and 4 deletions

View File

@ -341,6 +341,18 @@ fontInfoVersion3 = {
{"text" : "foo", "class" : ""},
]
),
"woffMetadataCopyright" : dict(
text=[
dict(text="foo"),
dict(text=""),
dict(text="foo", language="bar"),
dict(text="foo", language=""),
dict(text="foo", dir="ltr"),
dict(text="foo", dir="rtl"),
{"text" : "foo", "class" : "foo"},
{"text" : "foo", "class" : ""},
]
),
}
expectedFontInfo1To2Conversion = {

View File

@ -2181,6 +2181,73 @@ class ReadFontInfoVersion3TestCase(unittest.TestCase):
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# woffMetadataCopyright
## unknown attribute
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict(text=[dict(text="foo")], notTheRightKey=1)
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## no text
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict()
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text not a list
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict(text="abc")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text item not a dict
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict(text=["abc"])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text item unknown key
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict(text=[dict(text="foo", notTheRightKey=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text item missing text
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict(text=[dict(language="foo")])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text not a string
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict(text=[dict(text=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## url not a string
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict(text=[dict(text="foo", url=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## language not a string
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict(text=[dict(text="foo", language=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## dir not ltr or rtl
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict(text=[dict(text="foo", dir="utd")])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## class not a string
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict(text=[{"text" : "foo", "class" : 1}])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
class WriteFontInfoVersion1TestCase(unittest.TestCase):
@ -3970,6 +4037,51 @@ class WriteFontInfoVersion3TestCase(unittest.TestCase):
infoObject = self.makeInfoObject()
infoObject.woffMetadataLicense = dict(text=[{"text" : "foo", "class" : 1}])
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
# woffMetadataCopyright
## unknown attribute
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict(text=[dict(text="foo")], notTheRightKey=1)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
## no text
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict()
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
## text not a list
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict(text="abc")
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
## text item not a dict
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict(text=["abc"])
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
## text item unknown key
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict(text=[dict(text="foo", notTheRightKey=1)])
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
## text item missing text
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict(text=[dict(language="foo")])
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
## text not a string
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict(text=[dict(text=1)])
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
## url not a string
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict(text=[dict(text="foo", url=1)])
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
## language not a string
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict(text=[dict(text="foo", language=1)])
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
## dir not ltr or rtl
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict(text=[dict(text="foo", dir="utd")])
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
## class not a string
infoObject = self.makeInfoObject()
infoObject.woffMetadataCopyright = dict(text=[{"text" : "foo", "class" : 1}])
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
class UFO3ReadDataTestCase(unittest.TestCase):

View File

@ -1264,10 +1264,10 @@ def _fontInfoWOFFMetadataTrademarkValidator(value):
"""
Version 3+.
"""
dictPrototype = dict(text=(list, False))
dictPrototype = dict(text=(list, True))
if not _fontInfoDictValidator(value, dictPrototype):
return False
for text in value:
for text in value["text"]:
if not _fontInfoWOFFMetadataTextValue(text):
return False
return True
@ -1276,10 +1276,10 @@ def _fontInfoWOFFMetadataCopyrightValidator(value):
"""
Version 3+.
"""
dictPrototype = dict(text=(list, False))
dictPrototype = dict(text=(list, True))
if not _fontInfoDictValidator(value, dictPrototype):
return False
for text in value:
for text in value["text"]:
if not _fontInfoWOFFMetadataTextValue(text):
return False
return True
@ -1539,6 +1539,7 @@ _fontInfoAttributesVersion3ValueData.update({
"woffMetadataCredits" : dict(type=dict, valueValidator=_fontInfoWOFFMetadataCreditsValidator),
"woffMetadataDescription" : dict(type=dict, valueValidator=_fontInfoWOFFMetadataDescriptionValidator),
"woffMetadataLicense" : dict(type=dict, valueValidator=_fontInfoWOFFMetadataLicenseValidator),
"woffMetadataCopyright" : dict(type=dict, valueValidator=_fontInfoWOFFMetadataCopyrightValidator),
})
# insert the type validator for all attrs that