Merge pull request #1118 from anthrotype/empty-subrs
[subset] delete empty SubrsIndex after subsetting CFF
This commit is contained in:
commit
1d6dd50d52
@ -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()]
|
||||
|
@ -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">
|
||||
|
@ -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">
|
||||
|
@ -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>
|
||||
|
@ -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">
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user