More refactoring
This commit is contained in:
parent
8c8ff45c72
commit
a6dbb7ae2a
21
pyotlss.py
21
pyotlss.py
@ -672,6 +672,7 @@ def closure_glyphs (self, s):
|
|||||||
|
|
||||||
@add_method(fontTools.ttLib.getTableClass('GSUB'), fontTools.ttLib.getTableClass('GPOS'))
|
@add_method(fontTools.ttLib.getTableClass('GSUB'), fontTools.ttLib.getTableClass('GPOS'))
|
||||||
def subset_glyphs (self, s):
|
def subset_glyphs (self, s):
|
||||||
|
s.glyphs = s.glyphs_gsubed
|
||||||
lookup_indices = self.table.LookupList.subset_glyphs (s)
|
lookup_indices = self.table.LookupList.subset_glyphs (s)
|
||||||
self.subset_lookups (lookup_indices)
|
self.subset_lookups (lookup_indices)
|
||||||
self.prune_lookups ()
|
self.prune_lookups ()
|
||||||
@ -707,23 +708,24 @@ def prune_pre_subset (self, options):
|
|||||||
|
|
||||||
@add_method(fontTools.ttLib.getTableClass('GDEF'))
|
@add_method(fontTools.ttLib.getTableClass('GDEF'))
|
||||||
def subset_glyphs (self, s):
|
def subset_glyphs (self, s):
|
||||||
|
glyphs = s.glyphs_gsubed
|
||||||
table = self.table
|
table = self.table
|
||||||
if table.LigCaretList:
|
if table.LigCaretList:
|
||||||
indices = table.LigCaretList.Coverage.subset (s.glyphs)
|
indices = table.LigCaretList.Coverage.subset (glyphs)
|
||||||
table.LigCaretList.LigGlyph = [table.LigCaretList.LigGlyph[i] for i in indices]
|
table.LigCaretList.LigGlyph = [table.LigCaretList.LigGlyph[i] for i in indices]
|
||||||
table.LigCaretList.LigGlyphCount = len (table.LigCaretList.LigGlyph)
|
table.LigCaretList.LigGlyphCount = len (table.LigCaretList.LigGlyph)
|
||||||
if not table.LigCaretList.LigGlyphCount:
|
if not table.LigCaretList.LigGlyphCount:
|
||||||
table.LigCaretList = None
|
table.LigCaretList = None
|
||||||
if table.MarkAttachClassDef:
|
if table.MarkAttachClassDef:
|
||||||
table.MarkAttachClassDef.classDefs = {g:v for g,v in table.MarkAttachClassDef.classDefs.items() if g in s.glyphs}
|
table.MarkAttachClassDef.classDefs = {g:v for g,v in table.MarkAttachClassDef.classDefs.items() if g in glyphs}
|
||||||
if not table.MarkAttachClassDef.classDefs:
|
if not table.MarkAttachClassDef.classDefs:
|
||||||
table.MarkAttachClassDef = None
|
table.MarkAttachClassDef = None
|
||||||
if table.GlyphClassDef:
|
if table.GlyphClassDef:
|
||||||
table.GlyphClassDef.classDefs = {g:v for g,v in table.GlyphClassDef.classDefs.items() if g in s.glyphs}
|
table.GlyphClassDef.classDefs = {g:v for g,v in table.GlyphClassDef.classDefs.items() if g in glyphs}
|
||||||
if not table.GlyphClassDef.classDefs:
|
if not table.GlyphClassDef.classDefs:
|
||||||
table.GlyphClassDef = None
|
table.GlyphClassDef = None
|
||||||
if table.AttachList:
|
if table.AttachList:
|
||||||
indices = table.AttachList.Coverage.subset (s.glyphs)
|
indices = table.AttachList.Coverage.subset (glyphs)
|
||||||
table.AttachList.AttachPoint = [table.AttachList.AttachPoint[i] for i in indices]
|
table.AttachList.AttachPoint = [table.AttachList.AttachPoint[i] for i in indices]
|
||||||
table.AttachList.GlyphCount = len (table.AttachList.AttachPoint)
|
table.AttachList.GlyphCount = len (table.AttachList.AttachPoint)
|
||||||
if not table.AttachList.GlyphCount:
|
if not table.AttachList.GlyphCount:
|
||||||
@ -738,8 +740,9 @@ def prune_pre_subset (self, options):
|
|||||||
|
|
||||||
@add_method(fontTools.ttLib.getTableClass('kern'))
|
@add_method(fontTools.ttLib.getTableClass('kern'))
|
||||||
def subset_glyphs (self, s):
|
def subset_glyphs (self, s):
|
||||||
|
glyphs = s.glyphs_gsubed
|
||||||
for t in self.kernTables:
|
for t in self.kernTables:
|
||||||
t.kernTable = {(a,b):v for ((a,b),v) in t.kernTable.items() if a in s.glyphs and b in s.glyphs}
|
t.kernTable = {(a,b):v for ((a,b),v) in t.kernTable.items() if a in glyphs and b in glyphs}
|
||||||
self.kernTables = [t for t in self.kernTables if t.kernTable]
|
self.kernTables = [t for t in self.kernTables if t.kernTable]
|
||||||
return bool (self.kernTables)
|
return bool (self.kernTables)
|
||||||
|
|
||||||
@ -956,6 +959,7 @@ def prune_pre_subset (self, options):
|
|||||||
|
|
||||||
@add_method(fontTools.ttLib.getTableClass('cmap'))
|
@add_method(fontTools.ttLib.getTableClass('cmap'))
|
||||||
def subset_glyphs (self, s):
|
def subset_glyphs (self, s):
|
||||||
|
s.glyphs = s.glyphs_cmaped
|
||||||
for t in self.tables:
|
for t in self.tables:
|
||||||
# For reasons I don't understand I need this here
|
# For reasons I don't understand I need this here
|
||||||
# to force decompilation of the cmap format 14.
|
# to force decompilation of the cmap format 14.
|
||||||
@ -1182,12 +1186,7 @@ class Subsetter:
|
|||||||
self.log (tag, "subsetting not needed")
|
self.log (tag, "subsetting not needed")
|
||||||
elif hasattr (clazz, 'subset_glyphs'):
|
elif hasattr (clazz, 'subset_glyphs'):
|
||||||
table = font[tag]
|
table = font[tag]
|
||||||
if tag == 'cmap': # What else?
|
self.glyphs = self.glyphs_all
|
||||||
self.glyphs = self.glyphs_cmaped
|
|
||||||
elif tag in ['GSUB', 'GPOS', 'GDEF', 'cmap', 'kern', 'post']: # What else?
|
|
||||||
self.glyphs = self.glyphs_gsubed
|
|
||||||
else:
|
|
||||||
self.glyphs = self.glyphs_glyfed
|
|
||||||
retain = table.subset_glyphs (self)
|
retain = table.subset_glyphs (self)
|
||||||
self.log.lapse ("subset '%s'" % tag)
|
self.log.lapse ("subset '%s'" % tag)
|
||||||
if not retain:
|
if not retain:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user