Merge pull request #2 from tomarcher101/add-error-when-duplicate-in-kerning-group
Add code that removes duplicates when parsing groups.plist
This commit is contained in:
commit
5c8c6b3c92
@ -459,7 +459,12 @@ class UFOReader(_UFOBaseIO):
|
||||
# groups.plist
|
||||
|
||||
def _readGroups(self):
|
||||
return self._getPlist(GROUPS_FILENAME, {})
|
||||
groups = self._getPlist(GROUPS_FILENAME, {})
|
||||
# remove any duplicate glyphs in a kerning group
|
||||
for groupName, glyphList in groups.items():
|
||||
if groupName.startswith('public.kern1.') or groupName.startswith('public.kern2.'):
|
||||
groups[groupName] = list(OrderedDict.fromkeys(glyphList))
|
||||
return groups
|
||||
|
||||
def readGroups(self, validate=None):
|
||||
"""
|
||||
|
@ -4192,6 +4192,19 @@ class UFO3ReadDataTestCase(unittest.TestCase):
|
||||
fileObject = reader.getReadFileForPath("data/org.unifiedfontobject.doesNotExist")
|
||||
self.assertEqual(fileObject, None)
|
||||
|
||||
def testUFOReaderKernGroupDuplicatesRemoved(self):
|
||||
# Non-kerning group duplicates are kept
|
||||
# Kerning group duplicates are removed
|
||||
expected_groups = {
|
||||
"group1" : ["A"],
|
||||
"group2" : ["B", "C", "B"],
|
||||
"public.kern1.A" : ["A"],
|
||||
"public.kern2.B" : ["B", "A", "C"],
|
||||
}
|
||||
reader = UFOReader(self.getFontPath())
|
||||
groups = reader.readGroups()
|
||||
self.assertEqual(expected_groups, groups)
|
||||
|
||||
|
||||
class UFO3WriteDataTestCase(unittest.TestCase):
|
||||
|
||||
|
28
Tests/ufoLib/testdata/UFO3-Read Data.ufo/groups.plist
vendored
Normal file
28
Tests/ufoLib/testdata/UFO3-Read Data.ufo/groups.plist
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>group1</key>
|
||||
<array>
|
||||
<string>A</string>
|
||||
</array>
|
||||
<key>group2</key>
|
||||
<array>
|
||||
<string>B</string>
|
||||
<string>C</string>
|
||||
<string>B</string>
|
||||
</array>
|
||||
<key>public.kern1.A</key>
|
||||
<array>
|
||||
<string>A</string>
|
||||
</array>
|
||||
<key>public.kern2.B</key>
|
||||
<array>
|
||||
<string>B</string>
|
||||
<string>A</string>
|
||||
<string>B</string>
|
||||
<string>A</string>
|
||||
<string>C</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
Loading…
x
Reference in New Issue
Block a user