WOFF license.
git-svn-id: http://svn.robofab.com/branches/ufo3k@280 b5fa9d6c-a76f-4ffd-b3cb-f825fc41095c
This commit is contained in:
parent
08e57f95ff
commit
061df1317e
@ -326,7 +326,21 @@ fontInfoVersion3 = {
|
||||
{"text" : "foo", "class" : "foo"},
|
||||
{"text" : "foo", "class" : ""},
|
||||
]
|
||||
)
|
||||
),
|
||||
"woffMetadataLicense" : dict(
|
||||
url="http://somefoundry.com/foo/license",
|
||||
id="foo",
|
||||
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 = {
|
||||
|
@ -2102,6 +2102,85 @@ class ReadFontInfoVersion3TestCase(unittest.TestCase):
|
||||
self._writeInfoToPlist(info)
|
||||
reader = UFOReader(self.dstDir)
|
||||
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
|
||||
# woffMetadataLicense
|
||||
## no url
|
||||
info = dict(fontInfoVersion3)
|
||||
info["woffMetadataLicense"] = dict(text=[dict(text="foo")])
|
||||
self._writeInfoToPlist(info)
|
||||
reader = UFOReader(self.dstDir)
|
||||
reader.readInfo(TestInfoObject())
|
||||
## url not a string
|
||||
info = dict(fontInfoVersion3)
|
||||
info["woffMetadataLicense"] = dict(text=[dict(text="foo")], url=1)
|
||||
self._writeInfoToPlist(info)
|
||||
reader = UFOReader(self.dstDir)
|
||||
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
|
||||
## id not a string
|
||||
info = dict(fontInfoVersion3)
|
||||
info["woffMetadataLicense"] = dict(text=[dict(text="foo")], id=1)
|
||||
self._writeInfoToPlist(info)
|
||||
reader = UFOReader(self.dstDir)
|
||||
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
|
||||
## no text
|
||||
info = dict(fontInfoVersion3)
|
||||
info["woffMetadataLicense"] = dict(url="foo")
|
||||
self._writeInfoToPlist(info)
|
||||
reader = UFOReader(self.dstDir)
|
||||
reader.readInfo(TestInfoObject())
|
||||
## text not a list
|
||||
info = dict(fontInfoVersion3)
|
||||
info["woffMetadataLicense"] = 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["woffMetadataLicense"] = dict(text=["abc"])
|
||||
self._writeInfoToPlist(info)
|
||||
reader = UFOReader(self.dstDir)
|
||||
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
|
||||
## text item unknown key
|
||||
info = dict(fontInfoVersion3)
|
||||
info["woffMetadataLicense"] = 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["woffMetadataLicense"] = 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["woffMetadataLicense"] = 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["woffMetadataLicense"] = 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["woffMetadataLicense"] = 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["woffMetadataLicense"] = 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["woffMetadataLicense"] = dict(text=[{"text" : "foo", "class" : 1}])
|
||||
self._writeInfoToPlist(info)
|
||||
reader = UFOReader(self.dstDir)
|
||||
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
|
||||
|
||||
|
||||
class WriteFontInfoVersion1TestCase(unittest.TestCase):
|
||||
@ -3838,6 +3917,59 @@ class WriteFontInfoVersion3TestCase(unittest.TestCase):
|
||||
infoObject.woffMetadataDescription = dict(text=[{"text" : "foo", "class" : 1}])
|
||||
writer = UFOWriter(self.dstDir, formatVersion=3)
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
# woffMetadataLicense
|
||||
## no url
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=[dict(text="foo")])
|
||||
writer.writeInfo(TestInfoObject())
|
||||
## url not a string
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=[dict(text="foo")], url=1)
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
## id not a string
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=[dict(text="foo")], id=1)
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
## no text
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(url="foo")
|
||||
writer.writeInfo(TestInfoObject())
|
||||
## text not a list
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text="abc")
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
## text item not a dict
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=["abc"])
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
## text item unknown key
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=[dict(text="foo", notTheRightKey=1)])
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
## text item missing text
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=[dict(language="foo")])
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
## text not a string
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=[dict(text=1)])
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
## url not a string
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=[dict(text="foo", url=1)])
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
## language not a string
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=[dict(text="foo", language=1)])
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
## dir not ltr or rtl
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=[dict(text="foo", dir="utd")])
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
## class not a string
|
||||
infoObject = self.makeInfoObject()
|
||||
infoObject.woffMetadataLicense = dict(text=[{"text" : "foo", "class" : 1}])
|
||||
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
|
||||
|
||||
|
||||
class UFO3ReadDataTestCase(unittest.TestCase):
|
||||
|
@ -1251,12 +1251,13 @@ def _fontInfoWOFFMetadataLicenseValidator(value):
|
||||
"""
|
||||
Version 3+.
|
||||
"""
|
||||
dictPrototype = dict(url=(basestring, False), text=(list, False))
|
||||
dictPrototype = dict(url=(basestring, False), text=(list, False), id=(basestring, False))
|
||||
if not _fontInfoDictValidator(value, dictPrototype):
|
||||
return False
|
||||
for text in value:
|
||||
if not _fontInfoWOFFMetadataTextValue(text):
|
||||
return False
|
||||
if "text" in value:
|
||||
for text in value["text"]:
|
||||
if not _fontInfoWOFFMetadataTextValue(text):
|
||||
return False
|
||||
return True
|
||||
|
||||
def _fontInfoWOFFMetadataTrademarkValidator(value):
|
||||
@ -1537,6 +1538,7 @@ _fontInfoAttributesVersion3ValueData.update({
|
||||
"woffMetadataVendor" : dict(type=dict, valueValidator=_fontInfoWOFFMetadataVendorValidator),
|
||||
"woffMetadataCredits" : dict(type=dict, valueValidator=_fontInfoWOFFMetadataCreditsValidator),
|
||||
"woffMetadataDescription" : dict(type=dict, valueValidator=_fontInfoWOFFMetadataDescriptionValidator),
|
||||
"woffMetadataLicense" : dict(type=dict, valueValidator=_fontInfoWOFFMetadataLicenseValidator),
|
||||
})
|
||||
|
||||
# insert the type validator for all attrs that
|
||||
|
Loading…
x
Reference in New Issue
Block a user