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:
|
for subr in subrs.items:
|
||||||
subr.subset_subroutines (local_subrs, font.GlobalSubrs)
|
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
|
# Cleanup
|
||||||
for subrs in all_subrs:
|
for subrs in all_subrs:
|
||||||
del subrs._used, subrs._old_bias, subrs._new_bias
|
del subrs._used, subrs._old_bias, subrs._new_bias
|
||||||
|
|
||||||
return True
|
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'))
|
@_add_method(ttLib.getTableClass('cmap'))
|
||||||
def closure_glyphs(self, s):
|
def closure_glyphs(self, s):
|
||||||
tables = [t for t in self.tables if t.isUnicode()]
|
tables = [t for t in self.tables if t.isUnicode()]
|
||||||
|
@ -33,9 +33,6 @@
|
|||||||
<initialRandomSeed value="0"/>
|
<initialRandomSeed value="0"/>
|
||||||
<defaultWidthX value="267"/>
|
<defaultWidthX value="267"/>
|
||||||
<nominalWidthX value="448"/>
|
<nominalWidthX value="448"/>
|
||||||
<Subrs>
|
|
||||||
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
|
|
||||||
</Subrs>
|
|
||||||
</Private>
|
</Private>
|
||||||
<CharStrings>
|
<CharStrings>
|
||||||
<CharString name=".notdef">
|
<CharString name=".notdef">
|
||||||
|
@ -32,9 +32,6 @@
|
|||||||
<initialRandomSeed value="0"/>
|
<initialRandomSeed value="0"/>
|
||||||
<defaultWidthX value="267"/>
|
<defaultWidthX value="267"/>
|
||||||
<nominalWidthX value="448"/>
|
<nominalWidthX value="448"/>
|
||||||
<Subrs>
|
|
||||||
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
|
|
||||||
</Subrs>
|
|
||||||
</Private>
|
</Private>
|
||||||
<CharStrings>
|
<CharStrings>
|
||||||
<CharString name=".notdef">
|
<CharString name=".notdef">
|
||||||
|
@ -43,9 +43,6 @@
|
|||||||
<initialRandomSeed value="0"/>
|
<initialRandomSeed value="0"/>
|
||||||
<defaultWidthX value="1000"/>
|
<defaultWidthX value="1000"/>
|
||||||
<nominalWidthX value="107"/>
|
<nominalWidthX value="107"/>
|
||||||
<Subrs>
|
|
||||||
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
|
|
||||||
</Subrs>
|
|
||||||
</Private>
|
</Private>
|
||||||
</FontDict>
|
</FontDict>
|
||||||
</FDArray>
|
</FDArray>
|
||||||
|
@ -33,9 +33,6 @@
|
|||||||
<initialRandomSeed value="0"/>
|
<initialRandomSeed value="0"/>
|
||||||
<defaultWidthX value="500"/>
|
<defaultWidthX value="500"/>
|
||||||
<nominalWidthX value="300"/>
|
<nominalWidthX value="300"/>
|
||||||
<Subrs>
|
|
||||||
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
|
|
||||||
</Subrs>
|
|
||||||
</Private>
|
</Private>
|
||||||
<CharStrings>
|
<CharStrings>
|
||||||
<CharString name=".notdef">
|
<CharString name=".notdef">
|
||||||
|
@ -38,9 +38,6 @@
|
|||||||
<initialRandomSeed value="0"/>
|
<initialRandomSeed value="0"/>
|
||||||
<defaultWidthX value="602"/>
|
<defaultWidthX value="602"/>
|
||||||
<nominalWidthX value="630"/>
|
<nominalWidthX value="630"/>
|
||||||
<Subrs>
|
|
||||||
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
|
|
||||||
</Subrs>
|
|
||||||
</Private>
|
</Private>
|
||||||
</FontDict>
|
</FontDict>
|
||||||
<FontDict index="1">
|
<FontDict index="1">
|
||||||
@ -56,9 +53,6 @@
|
|||||||
<initialRandomSeed value="0"/>
|
<initialRandomSeed value="0"/>
|
||||||
<defaultWidthX value="1000"/>
|
<defaultWidthX value="1000"/>
|
||||||
<nominalWidthX value="107"/>
|
<nominalWidthX value="107"/>
|
||||||
<Subrs>
|
|
||||||
<!-- The 'index' attribute is only for humans; it is ignored when parsed. -->
|
|
||||||
</Subrs>
|
|
||||||
</Private>
|
</Private>
|
||||||
</FontDict>
|
</FontDict>
|
||||||
</FDArray>
|
</FDArray>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user