Merge pull request #673 from anthrotype/subset-passthrough-tables
[subset] add --passthrough-tables option
This commit is contained in:
commit
7a8d07d2c2
@ -216,11 +216,17 @@ Font table options:
|
|||||||
they do not need subsetting (ignore the fact that 'loca' is listed
|
they do not need subsetting (ignore the fact that 'loca' is listed
|
||||||
here): 'gasp', 'head', 'hhea', 'maxp', 'vhea', 'OS/2', 'loca',
|
here): 'gasp', 'head', 'hhea', 'maxp', 'vhea', 'OS/2', 'loca',
|
||||||
'name', 'cvt ', 'fpgm', 'prep', 'VMDX', 'DSIG' and 'CPAL'.
|
'name', 'cvt ', 'fpgm', 'prep', 'VMDX', 'DSIG' and 'CPAL'.
|
||||||
Tables that the tool does not know how to subset and are not specified
|
By default, tables that the tool does not know how to subset and are not
|
||||||
here will be dropped from the font.
|
specified here will be dropped from the font, unless --passthrough-tables
|
||||||
|
option is passed.
|
||||||
Example:
|
Example:
|
||||||
--no-subset-tables+=FFTM
|
--no-subset-tables+=FFTM
|
||||||
* Keep 'FFTM' table in the font by preventing subsetting.
|
* Keep 'FFTM' table in the font by preventing subsetting.
|
||||||
|
--passthrough-tables
|
||||||
|
Do not drop tables that the tool does not know how to subset.
|
||||||
|
--no-passthrough-tables
|
||||||
|
Tables that the tool does not know how to subset and are not specified
|
||||||
|
in --no-subset-tables will be dropped from the font. [default]
|
||||||
--hinting-tables[-]=<table>[,<table>...]
|
--hinting-tables[-]=<table>[,<table>...]
|
||||||
Specify (=), add to (+=) or exclude from (-=) the list of font-wide
|
Specify (=), add to (+=) or exclude from (-=) the list of font-wide
|
||||||
hinting tables that will be dropped if --no-hinting is specified,
|
hinting tables that will be dropped if --no-hinting is specified,
|
||||||
@ -2444,6 +2450,7 @@ class Options(object):
|
|||||||
|
|
||||||
self.drop_tables = self._drop_tables_default[:]
|
self.drop_tables = self._drop_tables_default[:]
|
||||||
self.no_subset_tables = self._no_subset_tables_default[:]
|
self.no_subset_tables = self._no_subset_tables_default[:]
|
||||||
|
self.passthrough_tables = False # keep/drop tables we can't subset
|
||||||
self.hinting_tables = self._hinting_tables_default[:]
|
self.hinting_tables = self._hinting_tables_default[:]
|
||||||
self.legacy_kern = False # drop 'kern' table if GPOS available
|
self.legacy_kern = False # drop 'kern' table if GPOS available
|
||||||
self.layout_features = self._layout_features_default[:]
|
self.layout_features = self._layout_features_default[:]
|
||||||
@ -2722,6 +2729,8 @@ class Subsetter(object):
|
|||||||
del font[tag]
|
del font[tag]
|
||||||
else:
|
else:
|
||||||
log.info("%s subsetted", tag)
|
log.info("%s subsetted", tag)
|
||||||
|
elif self.options.passthrough_tables:
|
||||||
|
log.info("%s NOT subset; don't know how to subset", tag)
|
||||||
else:
|
else:
|
||||||
log.info("%s NOT subset; don't know how to subset; dropped", tag)
|
log.info("%s NOT subset; don't know how to subset; dropped", tag)
|
||||||
del font[tag]
|
del font[tag]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from __future__ import print_function, division, absolute_import
|
from __future__ import print_function, division, absolute_import
|
||||||
from fontTools.misc.py23 import *
|
from fontTools.misc.py23 import *
|
||||||
from fontTools import subset
|
from fontTools import subset
|
||||||
from fontTools.ttLib import TTFont
|
from fontTools.ttLib import TTFont, newTable
|
||||||
import contextlib
|
import contextlib
|
||||||
import difflib
|
import difflib
|
||||||
import logging
|
import logging
|
||||||
@ -204,6 +204,29 @@ class SubsetTest(unittest.TestCase):
|
|||||||
self.assertTrue(filter(lambda l: l.args['msg'] == "subset 'cmap'", logs))
|
self.assertTrue(filter(lambda l: l.args['msg'] == "subset 'cmap'", logs))
|
||||||
self.assertTrue(filter(lambda l: l.args['msg'] == "subset 'glyf'", logs))
|
self.assertTrue(filter(lambda l: l.args['msg'] == "subset 'glyf'", logs))
|
||||||
|
|
||||||
|
def test_passthrough_tables(self):
|
||||||
|
_, fontpath = self.compile_font(self.getpath("TestTTF-Regular.ttx"), ".ttf")
|
||||||
|
font = TTFont(fontpath)
|
||||||
|
unknown_tag = 'ZZZZ'
|
||||||
|
unknown_table = newTable(unknown_tag)
|
||||||
|
unknown_table.data = b'\0'*10
|
||||||
|
font[unknown_tag] = unknown_table
|
||||||
|
font.save(fontpath)
|
||||||
|
|
||||||
|
subsetpath = self.temp_path(".ttf")
|
||||||
|
subset.main([fontpath, "--output-file=%s" % subsetpath])
|
||||||
|
subsetfont = TTFont(subsetpath)
|
||||||
|
|
||||||
|
# tables we can't subset are dropped by default
|
||||||
|
self.assertFalse(unknown_tag in subsetfont)
|
||||||
|
|
||||||
|
subsetpath = self.temp_path(".ttf")
|
||||||
|
subset.main([fontpath, "--passthrough-tables", "--output-file=%s" % subsetpath])
|
||||||
|
subsetfont = TTFont(subsetpath)
|
||||||
|
|
||||||
|
# unknown tables are kept if --passthrough-tables option is passed
|
||||||
|
self.assertTrue(unknown_tag in subsetfont)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user