[subset] Add --text-file

This commit is contained in:
Behdad Esfahbod 2014-08-13 16:55:47 -04:00
parent 1633d8e917
commit 3b34ea301a

View File

@ -65,7 +65,7 @@ Glyph set specification for subsetting:
Specify characters to include in the subset, as UTF-8 string. Specify characters to include in the subset, as UTF-8 string.
--text-file=<path> --text-file=<path>
Specify a text file containing characters to include in the subset, Specify a text file containing characters to include in the subset,
as UTF-8 string. as UTF-8 strings.
--notdef-glyph --notdef-glyph
Add the '.notdef' glyph to the subset (ie, keep it). [default] Add the '.notdef' glyph to the subset (ie, keep it). [default]
--no-notdef-glyph --no-notdef-glyph
@ -2413,7 +2413,7 @@ def main(args):
args = log.parse_opts(args) args = log.parse_opts(args)
options = Options() options = Options()
args = options.parse_opts(args, ignore_unknown=['text']) args = options.parse_opts(args, ignore_unknown=['text', 'text_file'])
if len(args) < 2: if len(args) < 2:
print("usage:", __usage__, file=sys.stderr) print("usage:", __usage__, file=sys.stderr)
@ -2448,6 +2448,9 @@ def main(args):
if g.startswith('--text='): if g.startswith('--text='):
text += g[7:] text += g[7:]
continue continue
if g.startswith('--text-file='):
text += ''.join(open(g[12:], 'r').readlines())
continue
if g.startswith('uni') or g.startswith('U+'): if g.startswith('uni') or g.startswith('U+'):
if g.startswith('uni') and len(g) > 3: if g.startswith('uni') and len(g) > 3:
g = g[3:] g = g[3:]