From 8e8da97a4c1a4fcceee8c36563dc903de93760d7 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 7 Feb 2019 01:58:22 +0100 Subject: [PATCH] [cffLib]: add clear() method to Index class to empty in-place --- Lib/fontTools/cffLib/__init__.py | 3 +++ Lib/fontTools/subset/cff.py | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/cffLib/__init__.py b/Lib/fontTools/cffLib/__init__.py index 868f93370..c1750479f 100644 --- a/Lib/fontTools/cffLib/__init__.py +++ b/Lib/fontTools/cffLib/__init__.py @@ -607,6 +607,9 @@ class Index(object): def getCompiler(self, strings, parent, isCFF2=None): return self.compilerClass(self, strings, parent, isCFF2=isCFF2) + def clear(self): + del self.items[:] + class GlobalSubrsIndex(Index): diff --git a/Lib/fontTools/subset/cff.py b/Lib/fontTools/subset/cff.py index ef204761a..dac66cc19 100644 --- a/Lib/fontTools/subset/cff.py +++ b/Lib/fontTools/subset/cff.py @@ -470,9 +470,7 @@ def desubroutinize(self): del pd.Subrs if 'Subrs' in pd.rawDict: del pd.rawDict['Subrs'] - # clear GlobalSubrsIndex - if cff.GlobalSubrs: - cff.GlobalSubrs.items = [] + cff.GlobalSubrs.clear() @_add_method(ttLib.getTableClass('CFF '))