blob: 3cfd7c8f882df458c79f885fbe5743ba47ee6591 [file] [log] [blame]
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
import os
import shutil
import unittest
import tempfile
from io import open
from fontTools.misc.py23 import unicode
from fontTools.ufoLib import UFOReader, UFOWriter, UFOLibError
from fontTools.ufoLib.glifLib import GlifLibError
from fontTools.misc import plistlib
from .testSupport import fontInfoVersion3
class TestInfoObject(object): pass
# --------------
# fontinfo.plist
# --------------
class ReadFontInfoVersion3TestCase(unittest.TestCase):
def setUp(self):
self.dstDir = tempfile.mktemp()
os.mkdir(self.dstDir)
metaInfo = {
"creator": "test",
"formatVersion": 3
}
path = os.path.join(self.dstDir, "metainfo.plist")
with open(path, "wb") as f:
plistlib.dump(metaInfo, f)
def tearDown(self):
shutil.rmtree(self.dstDir)
def _writeInfoToPlist(self, info):
path = os.path.join(self.dstDir, "fontinfo.plist")
with open(path, "wb") as f:
plistlib.dump(info, f)
def testRead(self):
originalData = dict(fontInfoVersion3)
self._writeInfoToPlist(originalData)
infoObject = TestInfoObject()
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(infoObject)
readData = {}
for attr in list(fontInfoVersion3.keys()):
readData[attr] = getattr(infoObject, attr)
self.assertEqual(originalData, readData)
def testGenericRead(self):
# familyName
info = dict(fontInfoVersion3)
info["familyName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# styleName
info = dict(fontInfoVersion3)
info["styleName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# styleMapFamilyName
info = dict(fontInfoVersion3)
info["styleMapFamilyName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# styleMapStyleName
## not a string
info = dict(fontInfoVersion3)
info["styleMapStyleName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## out of range
info = dict(fontInfoVersion3)
info["styleMapStyleName"] = "REGULAR"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# versionMajor
info = dict(fontInfoVersion3)
info["versionMajor"] = "1"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# versionMinor
info = dict(fontInfoVersion3)
info["versionMinor"] = "0"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["versionMinor"] = -1
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# copyright
info = dict(fontInfoVersion3)
info["copyright"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# trademark
info = dict(fontInfoVersion3)
info["trademark"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# unitsPerEm
info = dict(fontInfoVersion3)
info["unitsPerEm"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["unitsPerEm"] = -1
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["unitsPerEm"] = -1.0
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# descender
info = dict(fontInfoVersion3)
info["descender"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# xHeight
info = dict(fontInfoVersion3)
info["xHeight"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# capHeight
info = dict(fontInfoVersion3)
info["capHeight"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# ascender
info = dict(fontInfoVersion3)
info["ascender"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# italicAngle
info = dict(fontInfoVersion3)
info["italicAngle"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
def testGaspRead(self):
# not a list
info = dict(fontInfoVersion3)
info["openTypeGaspRangeRecords"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# empty list
info = dict(fontInfoVersion3)
info["openTypeGaspRangeRecords"] = []
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
# not a dict
info = dict(fontInfoVersion3)
info["openTypeGaspRangeRecords"] = ["abc"]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# dict not properly formatted
info = dict(fontInfoVersion3)
info["openTypeGaspRangeRecords"] = [dict(rangeMaxPPEM=0xFFFF, notTheRightKey=1)]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeGaspRangeRecords"] = [dict(notTheRightKey=1, rangeGaspBehavior=[0])]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# not an int for ppem
info = dict(fontInfoVersion3)
info["openTypeGaspRangeRecords"] = [dict(rangeMaxPPEM="abc", rangeGaspBehavior=[0]), dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0])]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# not a list for behavior
info = dict(fontInfoVersion3)
info["openTypeGaspRangeRecords"] = [dict(rangeMaxPPEM=10, rangeGaspBehavior="abc"), dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0])]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# invalid behavior value
info = dict(fontInfoVersion3)
info["openTypeGaspRangeRecords"] = [dict(rangeMaxPPEM=10, rangeGaspBehavior=[-1]), dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0])]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# not sorted
info = dict(fontInfoVersion3)
info["openTypeGaspRangeRecords"] = [dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0]), dict(rangeMaxPPEM=10, rangeGaspBehavior=[0])]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# no 0xFFFF
info = dict(fontInfoVersion3)
info["openTypeGaspRangeRecords"] = [dict(rangeMaxPPEM=10, rangeGaspBehavior=[0]), dict(rangeMaxPPEM=20, rangeGaspBehavior=[0])]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
def testHeadRead(self):
# openTypeHeadCreated
## not a string
info = dict(fontInfoVersion3)
info["openTypeHeadCreated"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## invalid format
info = dict(fontInfoVersion3)
info["openTypeHeadCreated"] = "2000-Jan-01 00:00:00"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeHeadLowestRecPPEM
info = dict(fontInfoVersion3)
info["openTypeHeadLowestRecPPEM"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeHeadLowestRecPPEM"] = -1
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeHeadFlags
info = dict(fontInfoVersion3)
info["openTypeHeadFlags"] = [-1]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
def testHheaRead(self):
# openTypeHheaAscender
info = dict(fontInfoVersion3)
info["openTypeHheaAscender"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeHheaDescender
info = dict(fontInfoVersion3)
info["openTypeHheaDescender"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeHheaLineGap
info = dict(fontInfoVersion3)
info["openTypeHheaLineGap"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeHheaCaretSlopeRise
info = dict(fontInfoVersion3)
info["openTypeHheaCaretSlopeRise"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeHheaCaretSlopeRun
info = dict(fontInfoVersion3)
info["openTypeHheaCaretSlopeRun"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeHheaCaretOffset
info = dict(fontInfoVersion3)
info["openTypeHheaCaretOffset"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
def testNameRead(self):
# openTypeNameDesigner
info = dict(fontInfoVersion3)
info["openTypeNameDesigner"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameDesignerURL
info = dict(fontInfoVersion3)
info["openTypeNameDesignerURL"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameManufacturer
info = dict(fontInfoVersion3)
info["openTypeNameManufacturer"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameManufacturerURL
info = dict(fontInfoVersion3)
info["openTypeNameManufacturerURL"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameLicense
info = dict(fontInfoVersion3)
info["openTypeNameLicense"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameLicenseURL
info = dict(fontInfoVersion3)
info["openTypeNameLicenseURL"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameVersion
info = dict(fontInfoVersion3)
info["openTypeNameVersion"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameUniqueID
info = dict(fontInfoVersion3)
info["openTypeNameUniqueID"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameDescription
info = dict(fontInfoVersion3)
info["openTypeNameDescription"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNamePreferredFamilyName
info = dict(fontInfoVersion3)
info["openTypeNamePreferredFamilyName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNamePreferredSubfamilyName
info = dict(fontInfoVersion3)
info["openTypeNamePreferredSubfamilyName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameCompatibleFullName
info = dict(fontInfoVersion3)
info["openTypeNameCompatibleFullName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameSampleText
info = dict(fontInfoVersion3)
info["openTypeNameSampleText"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameWWSFamilyName
info = dict(fontInfoVersion3)
info["openTypeNameWWSFamilyName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameWWSSubfamilyName
info = dict(fontInfoVersion3)
info["openTypeNameWWSSubfamilyName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeNameRecords
## not a list
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## not a dict
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = ["abc"]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## invalid dict structure
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [dict(foo="bar")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## incorrect keys
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID=1, platformID=1, encodingID=1, languageID=1, string="Name Record.", foo="bar")
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(platformID=1, encodingID=1, languageID=1, string="Name Record.")
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID=1, encodingID=1, languageID=1, string="Name Record.")
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID=1, platformID=1, languageID=1, string="Name Record.")
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID=1, platformID=1, encodingID=1, string="Name Record.")
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID=1, platformID=1, encodingID=1, languageID=1)
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## invalid values
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID="1", platformID=1, encodingID=1, languageID=1, string="Name Record.")
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID=1, platformID="1", encodingID=1, languageID=1, string="Name Record.")
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID=1, platformID=1, encodingID="1", languageID=1, string="Name Record.")
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID=1, platformID=1, encodingID=1, languageID="1", string="Name Record.")
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID=1, platformID=1, encodingID=1, languageID=1, string=1)
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## duplicate
info = dict(fontInfoVersion3)
info["openTypeNameRecords"] = [
dict(nameID=1, platformID=1, encodingID=1, languageID=1, string="Name Record."),
dict(nameID=1, platformID=1, encodingID=1, languageID=1, string="Name Record.")
]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
def testOS2Read(self):
# openTypeOS2WidthClass
## not an int
info = dict(fontInfoVersion3)
info["openTypeOS2WidthClass"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## out or range
info = dict(fontInfoVersion3)
info["openTypeOS2WidthClass"] = 15
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2WeightClass
info = dict(fontInfoVersion3)
## not an int
info["openTypeOS2WeightClass"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## out of range
info["openTypeOS2WeightClass"] = -50
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2Selection
info = dict(fontInfoVersion3)
info["openTypeOS2Selection"] = [-1]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2VendorID
info = dict(fontInfoVersion3)
info["openTypeOS2VendorID"] = 1234
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2Panose
## not an int
info = dict(fontInfoVersion3)
info["openTypeOS2Panose"] = [0, 1, 2, 3, 4, 5, 6, 7, 8, str(9)]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## negative
info = dict(fontInfoVersion3)
info["openTypeOS2Panose"] = [0, 1, 2, 3, 4, 5, 6, 7, 8, -9]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## too few values
info = dict(fontInfoVersion3)
info["openTypeOS2Panose"] = [0, 1, 2, 3]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## too many values
info = dict(fontInfoVersion3)
info["openTypeOS2Panose"] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2FamilyClass
## not an int
info = dict(fontInfoVersion3)
info["openTypeOS2FamilyClass"] = [1, str(1)]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## too few values
info = dict(fontInfoVersion3)
info["openTypeOS2FamilyClass"] = [1]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## too many values
info = dict(fontInfoVersion3)
info["openTypeOS2FamilyClass"] = [1, 1, 1]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## out of range
info = dict(fontInfoVersion3)
info["openTypeOS2FamilyClass"] = [1, 201]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2UnicodeRanges
## not an int
info = dict(fontInfoVersion3)
info["openTypeOS2UnicodeRanges"] = ["0"]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## out of range
info = dict(fontInfoVersion3)
info["openTypeOS2UnicodeRanges"] = [-1]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2CodePageRanges
## not an int
info = dict(fontInfoVersion3)
info["openTypeOS2CodePageRanges"] = ["0"]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## out of range
info = dict(fontInfoVersion3)
info["openTypeOS2CodePageRanges"] = [-1]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2TypoAscender
info = dict(fontInfoVersion3)
info["openTypeOS2TypoAscender"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2TypoDescender
info = dict(fontInfoVersion3)
info["openTypeOS2TypoDescender"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2TypoLineGap
info = dict(fontInfoVersion3)
info["openTypeOS2TypoLineGap"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2WinAscent
info = dict(fontInfoVersion3)
info["openTypeOS2WinAscent"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeOS2WinAscent"] = -1
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2WinDescent
info = dict(fontInfoVersion3)
info["openTypeOS2WinDescent"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
info = dict(fontInfoVersion3)
info["openTypeOS2WinDescent"] = -1
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2Type
## not an int
info = dict(fontInfoVersion3)
info["openTypeOS2Type"] = ["1"]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
## out of range
info = dict(fontInfoVersion3)
info["openTypeOS2Type"] = [-1]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2SubscriptXSize
info = dict(fontInfoVersion3)
info["openTypeOS2SubscriptXSize"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2SubscriptYSize
info = dict(fontInfoVersion3)
info["openTypeOS2SubscriptYSize"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2SubscriptXOffset
info = dict(fontInfoVersion3)
info["openTypeOS2SubscriptXOffset"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2SubscriptYOffset
info = dict(fontInfoVersion3)
info["openTypeOS2SubscriptYOffset"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2SuperscriptXSize
info = dict(fontInfoVersion3)
info["openTypeOS2SuperscriptXSize"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2SuperscriptYSize
info = dict(fontInfoVersion3)
info["openTypeOS2SuperscriptYSize"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2SuperscriptXOffset
info = dict(fontInfoVersion3)
info["openTypeOS2SuperscriptXOffset"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2SuperscriptYOffset
info = dict(fontInfoVersion3)
info["openTypeOS2SuperscriptYOffset"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2StrikeoutSize
info = dict(fontInfoVersion3)
info["openTypeOS2StrikeoutSize"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeOS2StrikeoutPosition
info = dict(fontInfoVersion3)
info["openTypeOS2StrikeoutPosition"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
def testVheaRead(self):
# openTypeVheaVertTypoAscender
info = dict(fontInfoVersion3)
info["openTypeVheaVertTypoAscender"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeVheaVertTypoDescender
info = dict(fontInfoVersion3)
info["openTypeVheaVertTypoDescender"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeVheaVertTypoLineGap
info = dict(fontInfoVersion3)
info["openTypeVheaVertTypoLineGap"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeVheaCaretSlopeRise
info = dict(fontInfoVersion3)
info["openTypeVheaCaretSlopeRise"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeVheaCaretSlopeRun
info = dict(fontInfoVersion3)
info["openTypeVheaCaretSlopeRun"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# openTypeVheaCaretOffset
info = dict(fontInfoVersion3)
info["openTypeVheaCaretOffset"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
def testFONDRead(self):
# macintoshFONDFamilyID
info = dict(fontInfoVersion3)
info["macintoshFONDFamilyID"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# macintoshFONDName
info = dict(fontInfoVersion3)
info["macintoshFONDName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
def testPostscriptRead(self):
# postscriptFontName
info = dict(fontInfoVersion3)
info["postscriptFontName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# postscriptFullName
info = dict(fontInfoVersion3)
info["postscriptFullName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# postscriptSlantAngle
info = dict(fontInfoVersion3)
info["postscriptSlantAngle"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject())
# postscriptUniqueID
info = dict(fontInfoVersion3)
info["postscriptUniqueID"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptUnderlineThickness
info = dict(fontInfoVersion3)
info["postscriptUnderlineThickness"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptUnderlinePosition
info = dict(fontInfoVersion3)
info["postscriptUnderlinePosition"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptIsFixedPitch
info = dict(fontInfoVersion3)
info["postscriptIsFixedPitch"] = 2
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptBlueValues
## not a list
info = dict(fontInfoVersion3)
info["postscriptBlueValues"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## uneven value count
info = dict(fontInfoVersion3)
info["postscriptBlueValues"] = [500]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## too many values
info = dict(fontInfoVersion3)
info["postscriptBlueValues"] = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptOtherBlues
## not a list
info = dict(fontInfoVersion3)
info["postscriptOtherBlues"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## uneven value count
info = dict(fontInfoVersion3)
info["postscriptOtherBlues"] = [500]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## too many values
info = dict(fontInfoVersion3)
info["postscriptOtherBlues"] = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptFamilyBlues
## not a list
info = dict(fontInfoVersion3)
info["postscriptFamilyBlues"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## uneven value count
info = dict(fontInfoVersion3)
info["postscriptFamilyBlues"] = [500]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## too many values
info = dict(fontInfoVersion3)
info["postscriptFamilyBlues"] = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptFamilyOtherBlues
## not a list
info = dict(fontInfoVersion3)
info["postscriptFamilyOtherBlues"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## uneven value count
info = dict(fontInfoVersion3)
info["postscriptFamilyOtherBlues"] = [500]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## too many values
info = dict(fontInfoVersion3)
info["postscriptFamilyOtherBlues"] = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptStemSnapH
## not list
info = dict(fontInfoVersion3)
info["postscriptStemSnapH"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## too many values
info = dict(fontInfoVersion3)
info["postscriptStemSnapH"] = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptStemSnapV
## not list
info = dict(fontInfoVersion3)
info["postscriptStemSnapV"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## too many values
info = dict(fontInfoVersion3)
info["postscriptStemSnapV"] = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptBlueFuzz
info = dict(fontInfoVersion3)
info["postscriptBlueFuzz"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptBlueShift
info = dict(fontInfoVersion3)
info["postscriptBlueShift"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptBlueScale
info = dict(fontInfoVersion3)
info["postscriptBlueScale"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptForceBold
info = dict(fontInfoVersion3)
info["postscriptForceBold"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptDefaultWidthX
info = dict(fontInfoVersion3)
info["postscriptDefaultWidthX"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptNominalWidthX
info = dict(fontInfoVersion3)
info["postscriptNominalWidthX"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptWeightName
info = dict(fontInfoVersion3)
info["postscriptWeightName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptDefaultCharacter
info = dict(fontInfoVersion3)
info["postscriptDefaultCharacter"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# postscriptWindowsCharacterSet
info = dict(fontInfoVersion3)
info["postscriptWindowsCharacterSet"] = -1
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# macintoshFONDFamilyID
info = dict(fontInfoVersion3)
info["macintoshFONDFamilyID"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# macintoshFONDName
info = dict(fontInfoVersion3)
info["macintoshFONDName"] = 123
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
def testWOFFRead(self):
# woffMajorVersion
info = dict(fontInfoVersion3)
info["woffMajorVersion"] = 1.0
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["woffMajorVersion"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# woffMinorVersion
info = dict(fontInfoVersion3)
info["woffMinorVersion"] = 1.0
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["woffMinorVersion"] = "abc"
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# woffMetadataUniqueID
## none
info = dict(fontInfoVersion3)
del info["woffMetadataUniqueID"]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
## not a dict
info = dict(fontInfoVersion3)
info["woffMetadataUniqueID"] = 1
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## unknown key
info = dict(fontInfoVersion3)
info["woffMetadataUniqueID"] = dict(id="foo", notTheRightKey=1)
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## no id
info = dict(fontInfoVersion3)
info["woffMetadataUniqueID"] = dict()
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## not a string for id
info = dict(fontInfoVersion3)
info["woffMetadataUniqueID"] = dict(id=1)
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## empty string
info = dict(fontInfoVersion3)
info["woffMetadataUniqueID"] = dict(id="")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
# woffMetadataVendor
## no name
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = dict(url="foo")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## name not a string
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = dict(name=1, url="foo")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## name an empty string
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = dict(name="", url="foo")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
## no URL
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = dict(name="foo")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
## url not a string
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = dict(name="foo", url=1)
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## url empty string
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = dict(name="foo", url="")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
## have dir
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = dict(name="foo", url="bar", dir="ltr")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = dict(name="foo", url="bar", dir="rtl")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
## dir not a string
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = dict(name="foo", url="bar", dir=1)
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## dir not ltr or rtl
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = dict(name="foo", url="bar", dir="utd")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## have class
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = {"name" : "foo", "url" : "bar", "class" : "hello"}
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
## class not a string
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = {"name" : "foo", "url" : "bar", "class" : 1}
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## class empty string
info = dict(fontInfoVersion3)
info["woffMetadataVendor"] = {"name" : "foo", "url" : "bar", "class" : ""}
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
# woffMetadataCredits
## no credits attribute
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = {}
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## unknown attribute
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=[dict(name="foo")], notTheRightKey=1)
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## not a list
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits="abc")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## no elements in credits
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=[])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## credit not a dict
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=["abc"])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## unknown key
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=[dict(name="foo", notTheRightKey=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## no name
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=[dict(url="foo")])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## name not a string
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=[dict(name=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## url not a string
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=[dict(name="foo", url=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## role not a string
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=[dict(name="foo", role=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## dir not a string
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=[dict(name="foo", dir=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## dir not ltr or rtl
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=[dict(name="foo", dir="utd")])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## class not a string
info = dict(fontInfoVersion3)
info["woffMetadataCredits"] = dict(credits=[{"name" : "foo", "class" : 1}])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# woffMetadataDescription
## no url
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text=[dict(text="foo")])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
## url not a string
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text=[dict(text="foo")], url=1)
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## no text
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(url="foo")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text not a list
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text="abc")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text item not a dict
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text=["abc"])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text item unknown key
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text=[dict(text="foo", notTheRightKey=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text item missing text
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text=[dict(language="foo")])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text not a string
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text=[dict(text=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## url not a string
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text=[dict(text="foo", url=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## language not a string
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text=[dict(text="foo", language=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## dir not ltr or rtl
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text=[dict(text="foo", dir="utd")])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## class not a string
info = dict(fontInfoVersion3)
info["woffMetadataDescription"] = dict(text=[{"text" : "foo", "class" : 1}])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## no text
info = dict(fontInfoVersion3)
info["woffMetadataLicense"] = dict(url="foo")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
## text not a list
info = dict(fontInfoVersion3)
info["woffMetadataLicense"] = dict(text="abc")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## no text
info = dict(fontInfoVersion3)
info["woffMetadataCopyright"] = dict()
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
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, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# woffMetadataTrademark
## unknown attribute
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict(text=[dict(text="foo")], notTheRightKey=1)
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## no text
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict()
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text not a list
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict(text="abc")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text item not a dict
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict(text=["abc"])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text item unknown key
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict(text=[dict(text="foo", notTheRightKey=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text item missing text
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict(text=[dict(language="foo")])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## text not a string
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict(text=[dict(text=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## url not a string
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict(text=[dict(text="foo", url=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## language not a string
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict(text=[dict(text="foo", language=1)])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## dir not ltr or rtl
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict(text=[dict(text="foo", dir="utd")])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## class not a string
info = dict(fontInfoVersion3)
info["woffMetadataTrademark"] = dict(text=[{"text" : "foo", "class" : 1}])
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# woffMetadataLicensee
## no name
info = dict(fontInfoVersion3)
info["woffMetadataLicensee"] = dict()
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## unknown attribute
info = dict(fontInfoVersion3)
info["woffMetadataLicensee"] = dict(name="foo", notTheRightKey=1)
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## name not a string
info = dict(fontInfoVersion3)
info["woffMetadataLicensee"] = dict(name=1)
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## dir options
info = dict(fontInfoVersion3)
info["woffMetadataLicensee"] = dict(name="foo", dir="ltr")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
info = dict(fontInfoVersion3)
info["woffMetadataLicensee"] = dict(name="foo", dir="rtl")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
## dir not ltr or rtl
info = dict(fontInfoVersion3)
info["woffMetadataLicensee"] = dict(name="foo", dir="utd")
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## have class
info = dict(fontInfoVersion3)
info["woffMetadataLicensee"] = {"name" : "foo", "class" : "hello"}
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
reader.readInfo(TestInfoObject())
## class not a string
info = dict(fontInfoVersion3)
info["woffMetadataLicensee"] = {"name" : "foo", "class" : 1}
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
def testGuidelinesRead(self):
# x
## not an int or float
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x="1")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# y
## not an int or float
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(y="1")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# angle
## < 0
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, y=0, angle=-1)]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## > 360
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, y=0, angle=361)]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# name
## not a string
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, name=1)]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# color
## not a string
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color=1)]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## not enough commas
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="1 0, 0, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="1 0 0, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="1 0 0 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## not enough parts
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color=", 0, 0, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="1, , 0, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="1, 0, , 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="1, 0, 0, ")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color=", , , ")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## not a number in all positions
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="r, 1, 1, 1")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="1, g, 1, 1")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="1, 1, b, 1")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="1, 1, 1, a")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## too many parts
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="1, 0, 0, 0, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## < 0 in each position
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="-1, 0, 0, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="0, -1, 0, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="0, 0, -1, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="0, 0, 0, -1")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
## > 1 in each position
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="2, 0, 0, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="0, 2, 0, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="0, 0, 2, 0")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, color="0, 0, 0, 2")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
# identifier
## duplicate
info = dict(fontInfoVersion3)
info["guidelines"] = [dict(x=0, identifier="guide1"), dict(y=0, identifier="guide1")]
self._writeInfoToPlist(info)
reader = UFOReader(self.dstDir, validate=True)
self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject())
class WriteFontInfoVersion3TestCase(unittest.TestCase):
def setUp(self):
self.tempDir = tempfile.mktemp()
os.mkdir(self.tempDir)
self.dstDir = os.path.join(self.tempDir, "test.ufo")
def tearDown(self):
shutil.rmtree(self.tempDir)
def tearDownUFO(self):
if os.path.exists(self.dstDir):
shutil.rmtree(self.dstDir)
def makeInfoObject(self):
infoObject = TestInfoObject()
for attr, value in list(fontInfoVersion3.items()):
setattr(infoObject, attr, value)
return infoObject
def readPlist(self):
path = os.path.join(self.dstDir, "fontinfo.plist")
with open(path, "rb") as f:
plist = plistlib.load(f)
return plist
def testWrite(self):
infoObject = self.makeInfoObject()
writer = UFOWriter(self.dstDir, formatVersion=3)
writer.writeInfo(infoObject)
writtenData = self.readPlist()
for attr, originalValue in list(fontInfoVersion3.items()):
newValue = writtenData[attr]
self.assertEqual(newValue, originalValue)
self.tearDownUFO()
def testGenericWrite(self):
# familyName
infoObject = self.makeInfoObject()
infoObject.familyName = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# styleName
infoObject = self.makeInfoObject()
infoObject.styleName = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# styleMapFamilyName
infoObject = self.makeInfoObject()
infoObject.styleMapFamilyName = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# styleMapStyleName
## not a string
infoObject = self.makeInfoObject()
infoObject.styleMapStyleName = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
## out of range
infoObject = self.makeInfoObject()
infoObject.styleMapStyleName = "REGULAR"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# versionMajor
infoObject = self.makeInfoObject()
infoObject.versionMajor = "1"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# versionMinor
infoObject = self.makeInfoObject()
infoObject.versionMinor = "0"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# copyright
infoObject = self.makeInfoObject()
infoObject.copyright = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# trademark
infoObject = self.makeInfoObject()
infoObject.trademark = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# unitsPerEm
infoObject = self.makeInfoObject()
infoObject.unitsPerEm = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# descender
infoObject = self.makeInfoObject()
infoObject.descender = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# xHeight
infoObject = self.makeInfoObject()
infoObject.xHeight = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# capHeight
infoObject = self.makeInfoObject()
infoObject.capHeight = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# ascender
infoObject = self.makeInfoObject()
infoObject.ascender = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# italicAngle
infoObject = self.makeInfoObject()
infoObject.italicAngle = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
def testGaspWrite(self):
# not a list
infoObject = self.makeInfoObject()
infoObject.openTypeGaspRangeRecords = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# empty list
infoObject = self.makeInfoObject()
infoObject.openTypeGaspRangeRecords = []
writer = UFOWriter(self.dstDir, formatVersion=3)
writer.writeInfo(infoObject)
self.tearDownUFO()
# not a dict
infoObject = self.makeInfoObject()
infoObject.openTypeGaspRangeRecords = ["abc"]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# dict not properly formatted
infoObject = self.makeInfoObject()
infoObject.openTypeGaspRangeRecords = [dict(rangeMaxPPEM=0xFFFF, notTheRightKey=1)]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
infoObject = self.makeInfoObject()
infoObject.openTypeGaspRangeRecords = [dict(notTheRightKey=1, rangeGaspBehavior=[0])]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# not an int for ppem
infoObject = self.makeInfoObject()
infoObject.openTypeGaspRangeRecords = [dict(rangeMaxPPEM="abc", rangeGaspBehavior=[0]), dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0])]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# not a list for behavior
infoObject = self.makeInfoObject()
infoObject.openTypeGaspRangeRecords = [dict(rangeMaxPPEM=10, rangeGaspBehavior="abc"), dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0])]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# invalid behavior value
infoObject = self.makeInfoObject()
infoObject.openTypeGaspRangeRecords = [dict(rangeMaxPPEM=10, rangeGaspBehavior=[-1]), dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0])]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# not sorted
infoObject = self.makeInfoObject()
infoObject.openTypeGaspRangeRecords = [dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0]), dict(rangeMaxPPEM=10, rangeGaspBehavior=[0])]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# no 0xFFFF
infoObject = self.makeInfoObject()
infoObject.openTypeGaspRangeRecords = [dict(rangeMaxPPEM=10, rangeGaspBehavior=[0]), dict(rangeMaxPPEM=20, rangeGaspBehavior=[0])]
writer = UFOWriter(self.dstDir, formatVersion=3)
writer.writeInfo(infoObject)
self.tearDownUFO()
def testHeadWrite(self):
# openTypeHeadCreated
## not a string
infoObject = self.makeInfoObject()
infoObject.openTypeHeadCreated = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
## invalid format
infoObject = self.makeInfoObject()
infoObject.openTypeHeadCreated = "2000-Jan-01 00:00:00"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeHeadLowestRecPPEM
infoObject = self.makeInfoObject()
infoObject.openTypeHeadLowestRecPPEM = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeHeadFlags
infoObject = self.makeInfoObject()
infoObject.openTypeHeadFlags = [-1]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
def testHheaWrite(self):
# openTypeHheaAscender
infoObject = self.makeInfoObject()
infoObject.openTypeHheaAscender = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeHheaDescender
infoObject = self.makeInfoObject()
infoObject.openTypeHheaDescender = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeHheaLineGap
infoObject = self.makeInfoObject()
infoObject.openTypeHheaLineGap = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeHheaCaretSlopeRise
infoObject = self.makeInfoObject()
infoObject.openTypeHheaCaretSlopeRise = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeHheaCaretSlopeRun
infoObject = self.makeInfoObject()
infoObject.openTypeHheaCaretSlopeRun = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeHheaCaretOffset
infoObject = self.makeInfoObject()
infoObject.openTypeHheaCaretOffset = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
def testNameWrite(self):
# openTypeNameDesigner
infoObject = self.makeInfoObject()
infoObject.openTypeNameDesigner = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameDesignerURL
infoObject = self.makeInfoObject()
infoObject.openTypeNameDesignerURL = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameManufacturer
infoObject = self.makeInfoObject()
infoObject.openTypeNameManufacturer = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameManufacturerURL
infoObject = self.makeInfoObject()
infoObject.openTypeNameManufacturerURL = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameLicense
infoObject = self.makeInfoObject()
infoObject.openTypeNameLicense = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameLicenseURL
infoObject = self.makeInfoObject()
infoObject.openTypeNameLicenseURL = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameVersion
infoObject = self.makeInfoObject()
infoObject.openTypeNameVersion = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameUniqueID
infoObject = self.makeInfoObject()
infoObject.openTypeNameUniqueID = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameDescription
infoObject = self.makeInfoObject()
infoObject.openTypeNameDescription = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNamePreferredFamilyName
infoObject = self.makeInfoObject()
infoObject.openTypeNamePreferredFamilyName = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNamePreferredSubfamilyName
infoObject = self.makeInfoObject()
infoObject.openTypeNamePreferredSubfamilyName = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameCompatibleFullName
infoObject = self.makeInfoObject()
infoObject.openTypeNameCompatibleFullName = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameSampleText
infoObject = self.makeInfoObject()
infoObject.openTypeNameSampleText = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameWWSFamilyName
infoObject = self.makeInfoObject()
infoObject.openTypeNameWWSFamilyName = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameWWSSubfamilyName
infoObject = self.makeInfoObject()
infoObject.openTypeNameWWSSubfamilyName = 123
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
# openTypeNameRecords
## not a list
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = "abc"
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
## not a dict
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = ["abc"]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
## invalid dict structure
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [dict(foo="bar")]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
## incorrect keys
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID=1, platformID=1, encodingID=1, languageID=1, string="Name Record.", foo="bar")
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(platformID=1, encodingID=1, languageID=1, string="Name Record.")
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID=1, encodingID=1, languageID=1, string="Name Record.")
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID=1, platformID=1, languageID=1, string="Name Record.")
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID=1, platformID=1, encodingID=1, string="Name Record.")
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID=1, platformID=1, encodingID=1, languageID=1)
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
## invalid values
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID="1", platformID=1, encodingID=1, languageID=1, string="Name Record.")
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID=1, platformID="1", encodingID=1, languageID=1, string="Name Record.")
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID=1, platformID=1, encodingID="1", languageID=1, string="Name Record.")
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID=1, platformID=1, encodingID=1, languageID="1", string="Name Record.")
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID=1, platformID=1, encodingID=1, languageID=1, string=1)
]
writer = UFOWriter(self.dstDir, formatVersion=3)
self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject)
self.tearDownUFO()
## duplicate
infoObject = self.makeInfoObject()
infoObject.openTypeNameRecords = [
dict(nameID=1, platformID=1, encodingID=1, languageID=1, string="Name Record."),
dict(nameID=1, platformID=1, encodingID=1, languageID=1, string="Name Record.")
]
writer = UFOWriter(self.dstDir, formatVersion=3)
writer.writeInfo(infoObject)
def testOS2Write(self):
# openTypeOS2WidthClass
## not an int
infoObject = self.makeInfoObject()