Merge pull request #1118 from anthrotype/empty-subrs

[subset] delete empty SubrsIndex after subsetting CFF
This commit is contained in:
Cosimo Lupo 2017-11-28 11:55:08 +01:00 committed by GitHub
commit 1d6dd50d52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 18 deletions

View File

@ -2407,12 +2407,27 @@ def prune_post_subset(self, options):
for subr in subrs.items:
subr.subset_subroutines (local_subrs, font.GlobalSubrs)
# Delete local SubrsIndex if empty
if hasattr(font, 'FDSelect'):
for fd in font.FDArray:
_delete_empty_subrs(fd.Private)
else:
_delete_empty_subrs(font.Private)
# Cleanup
for subrs in all_subrs:
del subrs._used, subrs._old_bias, subrs._new_bias
return True
def _delete_empty_subrs(private_dict):
if hasattr(private_dict, 'Subrs') and not private_dict.Subrs:
if 'Subrs' in private_dict.rawDict:
del private_dict.rawDict['Subrs']
del private_dict.Subrs
@_add_method(ttLib.getTableClass('cmap'))
def closure_glyphs(self, s):
tables = [t for t in self.tables if t.isUnicode()]

View File

@ -33,9 +33,6 @@
<initialRandomSeed value="0"/>
<defaultWidthX value="267"/>
<nominalWidthX value="448"/>
<Subrs>
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
</Subrs>
</Private>
<CharStrings>
<CharString name=".notdef">

View File

@ -32,9 +32,6 @@
<initialRandomSeed value="0"/>
<defaultWidthX value="267"/>
<nominalWidthX value="448"/>
<Subrs>
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
</Subrs>
</Private>
<CharStrings>
<CharString name=".notdef">

View File

@ -43,9 +43,6 @@
<initialRandomSeed value="0"/>
<defaultWidthX value="1000"/>
<nominalWidthX value="107"/>
<Subrs>
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
</Subrs>
</Private>
</FontDict>
</FDArray>

View File

@ -33,9 +33,6 @@
<initialRandomSeed value="0"/>
<defaultWidthX value="500"/>
<nominalWidthX value="300"/>
<Subrs>
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
</Subrs>
</Private>
<CharStrings>
<CharString name=".notdef">

View File

@ -38,9 +38,6 @@
<initialRandomSeed value="0"/>
<defaultWidthX value="602"/>
<nominalWidthX value="630"/>
<Subrs>
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
</Subrs>
</Private>
</FontDict>
<FontDict index="1">
@ -56,9 +53,6 @@
<initialRandomSeed value="0"/>
<defaultWidthX value="1000"/>
<nominalWidthX value="107"/>
<Subrs>
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
</Subrs>
</Private>
</FontDict>
</FDArray>