Beispiel #1
0
 def validateKerning(self):
     " Make sure the kerning validates before saving. "
     self.logger.info("Validating kerning %s", os.path.basename(self.path))
     validates, errors, pairs = kerningValidatorReportPairs(self.font.kerning, self.font.groups)
     if validates:
         return
     for pair in pairs:
         if pair in self.font.kerning:
             del self.font.kerning[pair]
     for err in errors:
         self._kerningValidationProblems.append(err)
Beispiel #2
0
 def validateKerning(self):
     " Make sure the kerning validates before saving. "
     self.logger.info("Validating kerning %s", os.path.basename(self.path))
     validates, errors, pairs = kerningValidatorReportPairs(
         self.font.kerning, self.font.groups)
     if validates:
         return
     for pair in pairs:
         if pair in self.font.kerning:
             del self.font.kerning[pair]
     for err in errors:
         self._kerningValidationProblems.append(err)
Beispiel #3
0
def makeTestFonts(rootPath):
    """ Make some test fonts that have the kerning problem."""
    path1 = os.path.join(rootPath, "validMaster1.ufo")
    path2 = os.path.join(rootPath, "validMaster2.ufo")
    path3 = os.path.join(rootPath, "invalidInstance.ufo")

    # Two masters
    f1 = Font()
    f1.groups['public.kern1.@MMK_L_one'] = ['glyphOne', 'glyphTwo']
    f1.groups['public.kern2.@MMK_R_two'] = ['glyphThree', 'glyphFour']
    addGlyphs(f1)

    f2 = Font()
    f2.groups.update(f1.groups)
    # both masters have the same groups

    addGlyphs(f2)
    assert f1.groups == f2.groups

    # a normal group / group pair in each master
    f1.kerning[('public.kern1.@MMK_L_one', 'public.kern2.@MMK_R_two')] = 1000
    f1.kerning[('a', 'b')] = 10
    f2.kerning[('public.kern1.@MMK_L_one', 'public.kern2.@MMK_R_two')] = 2000
    f2.kerning[('a', 'b')] = 10

    # a valid exception to this pair in each master
    f1.kerning[('public.kern1.@MMK_L_one', 'glyphThree')] = -500
    f2.kerning[('glyphOne', 'public.kern2.@MMK_R_two')] = -800

    # make sure the kerning and groups in each master validate.
    assert kerningValidatorReportPairs(f1.kerning, f1.groups) == (True, [], [])
    assert kerningValidatorReportPairs(f2.kerning, f2.groups) == (True, [], [])

    # save
    f1.save(path1, 3)
    f2.save(path2, 3)
    return path1, path2, path3
Beispiel #4
0
def makeTestFonts(rootPath):
    """ Make some test fonts that have the kerning problem."""
    path1 = os.path.join(rootPath, "validMaster1.ufo")
    path2 = os.path.join(rootPath, "validMaster2.ufo")
    path3 = os.path.join(rootPath, "invalidInstance.ufo")

    # Two masters
    f1 = Font()
    f1.groups['public.kern1.@MMK_L_one'] = ['glyphOne', 'glyphTwo']
    f1.groups['public.kern2.@MMK_R_two'] = ['glyphThree', 'glyphFour']
    addGlyphs(f1)

    f2 = Font()
    f2.groups.update(f1.groups)
    # both masters have the same groups

    addGlyphs(f2)
    assert f1.groups == f2.groups

    # a normal group / group pair in each master
    f1.kerning[('public.kern1.@MMK_L_one', 'public.kern2.@MMK_R_two')] = 1000
    f1.kerning[('a', 'b')] = 10
    f2.kerning[('public.kern1.@MMK_L_one', 'public.kern2.@MMK_R_two')] = 2000
    f2.kerning[('a', 'b')] = 10

    # a valid exception to this pair in each master
    f1.kerning[('public.kern1.@MMK_L_one', 'glyphThree')] = -500
    f2.kerning[('glyphOne', 'public.kern2.@MMK_R_two')] = -800

    # make sure the kerning and groups in each master validate.
    assert kerningValidatorReportPairs(f1.kerning, f1.groups) == (True, [], [])
    assert kerningValidatorReportPairs(f2.kerning, f2.groups) == (True, [], [])

    # save
    f1.save(path1, 3)
    f2.save(path2, 3)
    return path1, path2, path3