diff --git a/Lib/fontTools/subset/__init__.py b/Lib/fontTools/subset/__init__.py index b2aac6c05..60f933ea7 100644 --- a/Lib/fontTools/subset/__init__.py +++ b/Lib/fontTools/subset/__init__.py @@ -1844,9 +1844,9 @@ def prune_pre_subset(self, font, options): if options.notdef_glyph and not options.notdef_outline: for fontname in cff.keys(): font = cff[fontname] - c,sel = font.CharStrings.getItemAndSelector('.notdef') + c, fdSelectIndex = font.CharStrings.getItemAndSelector('.notdef') if hasattr(font, 'FDArray') and font.FDArray is not None: - private = font.FDArray[font.FDSelect[sel]].Private + private = font.FDArray[fdSelectIndex].Private else: private = font.Private dfltWdX = private.defaultWidthX @@ -1876,7 +1876,7 @@ def subset_glyphs(self, s): # Load all glyphs for g in font.charset: if g not in s.glyphs: continue - c,sel = cs.getItemAndSelector(g) + c, _ = cs.getItemAndSelector(g) if cs.charStringsAreIndexed: indices = [i for i,g in enumerate(font.charset) if g in s.glyphs] @@ -2177,7 +2177,7 @@ def prune_post_subset(self, options): # Desubroutinize if asked for if options.desubroutinize: for g in font.charset: - c,sel = cs.getItemAndSelector(g) + c, _ = cs.getItemAndSelector(g) c.decompile() subrs = getattr(c.private, "Subrs", []) decompiler = _DesubroutinizingT2Decompiler(subrs, c.globalSubrs) @@ -2204,7 +2204,7 @@ def prune_post_subset(self, options): # thing, recursively... Good luck understanding that :( css = set() for g in font.charset: - c,sel = cs.getItemAndSelector(g) + c, _ = cs.getItemAndSelector(g) c.decompile() subrs = getattr(c.private, "Subrs", []) decompiler = _DehintingT2Decompiler(css, subrs, c.globalSubrs, @@ -2234,7 +2234,7 @@ def prune_post_subset(self, options): # Mark all used subroutines for g in font.charset: - c,sel = cs.getItemAndSelector(g) + c, _ = cs.getItemAndSelector(g) subrs = getattr(c.private, "Subrs", []) decompiler = _MarkingT2Decompiler(subrs, c.globalSubrs) decompiler.execute(c) @@ -2257,7 +2257,7 @@ def prune_post_subset(self, options): # Renumber glyph charstrings for g in font.charset: - c,sel = cs.getItemAndSelector(g) + c, _ = cs.getItemAndSelector(g) subrs = getattr(c.private, "Subrs", []) c.subset_subroutines (subrs, font.GlobalSubrs) diff --git a/Tests/subset/data/NotdefWidthCID-Regular.ttx b/Tests/subset/data/NotdefWidthCID-Regular.ttx new file mode 100644 index 000000000..ddb1b0fef --- /dev/null +++ b/Tests/subset/data/NotdefWidthCID-Regular.ttx @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Notdef Width CID + + + Regular + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -120 50 900 50 hstem + 100 50 700 50 vstem + 100 -120 rmoveto + 800 1000 -800 hlineto + 400 -459 rmoveto + -318 409 rlineto + 636 hlineto + -286 -450 rmoveto + 318 409 rlineto + -818 vlineto + -668 -41 rmoveto + 318 409 318 -409 rlineto + -668 859 rmoveto + 318 -409 -318 -409 rlineto + endchar + + + -407 endchar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/subset/data/expect_notdef_width_cid.ttx b/Tests/subset/data/expect_notdef_width_cid.ttx new file mode 100644 index 000000000..c0bab754f --- /dev/null +++ b/Tests/subset/data/expect_notdef_width_cid.ttx @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + endchar + + + -407 endchar + + + + + + + + + + diff --git a/Tests/subset/subset_test.py b/Tests/subset/subset_test.py index 3e12be8cd..3ed1d3349 100644 --- a/Tests/subset/subset_test.py +++ b/Tests/subset/subset_test.py @@ -265,6 +265,14 @@ class SubsetTest(unittest.TestCase): for tag in subset.Options().hinting_tables: self.assertTrue(tag not in subsetfont) + def test_notdef_width_cid(self): + # https://github.com/fonttools/fonttools/pull/845 + _, fontpath = self.compile_font(self.getpath("NotdefWidthCID-Regular.ttx"), ".otf") + subsetpath = self.temp_path(".otf") + subset.main([fontpath, "--no-notdef-outline", "--gids=0,1", "--output-file=%s" % subsetpath]) + subsetfont = TTFont(subsetpath) + self.expect_ttx(subsetfont, self.getpath("expect_notdef_width_cid.ttx"), ["CFF "]) + if __name__ == "__main__": sys.exit(unittest.main())