Get test working that shows duplicates are removed
This commit is contained in:
parent
2b654a1d2a
commit
b88f717885
@ -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):
|
||||
"""
|
||||
@ -476,10 +481,6 @@ class UFOReader(_UFOBaseIO):
|
||||
# normal
|
||||
else:
|
||||
groups = self._readGroups()
|
||||
# remove any duplicate glyphs in a kerning group
|
||||
for groupName, glyphList in groups.items():
|
||||
if groupName.startswith('public.kern1.') or groupName.startswith('public.kern2.'):
|
||||
glyphList = list(OrderedDict.fromkeys(glyphList))
|
||||
if validate:
|
||||
valid, message = groupsValidator(groups)
|
||||
if not valid:
|
||||
|
@ -4192,6 +4192,20 @@ class UFO3ReadDataTestCase(unittest.TestCase):
|
||||
fileObject = reader.getReadFileForPath("data/org.unifiedfontobject.doesNotExist")
|
||||
self.assertEqual(fileObject, None)
|
||||
|
||||
def testUFOReaderGroupDuplicatesRemoved(self):
|
||||
# Non-kerning group duplicates are kept
|
||||
# Kerning group duplicates are removed
|
||||
expected_groups = {
|
||||
"group1" : ["A"],
|
||||
"group2" : ["B", "B"],
|
||||
"public.kern1.A" : ["A"],
|
||||
"public.kern2.B" : ["B"],
|
||||
}
|
||||
reader = UFOReader(self.getFontPath())
|
||||
groups = reader.readGroups()
|
||||
import pdb; pdb.set_trace()
|
||||
self.assertEqual(expected_groups, groups)
|
||||
|
||||
|
||||
class UFO3WriteDataTestCase(unittest.TestCase):
|
||||
|
||||
|
24
Tests/ufoLib/testdata/UFO3-Read Data.ufo/groups.plist
vendored
Normal file
24
Tests/ufoLib/testdata/UFO3-Read Data.ufo/groups.plist
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
<?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>B</string>
|
||||
</array>
|
||||
<key>public.kern1.A</key>
|
||||
<array>
|
||||
<string>A</string>
|
||||
</array>
|
||||
<key>public.kern2.B</key>
|
||||
<array>
|
||||
<string>B</string>
|
||||
<string>B</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
Loading…
x
Reference in New Issue
Block a user