Fonttools: No '--help' for pyftmerge, traceback instead.

Created on 15 Feb 2016  路  3Comments  路  Source: fonttools/fonttools

I naively did pyftmerge --help, but that results in a traceback:

Traceback (most recent call last):
  File "/Users/just/code/git/fonttools/Tools/pyftmerge", line 6, in <module>
    merge.main(sys.argv[1:])
  File "/Users/just/code/git/fonttools/Tools/fontTools/misc/loggingTools.py", line 369, in wrapper
    return func(*args, **kwds)
  File "/Users/just/code/git/fonttools/Tools/fontTools/merge.py", line 896, in main
    args = options.parse_opts(args)
  File "/Users/just/code/git/fonttools/Tools/fontTools/merge.py", line 696, in parse_opts
    if ignore_unknown is True or k in ignore_unknown:
TypeError: argument of type 'bool' is not iterable

Most helpful comment

For those wondering, this is how to use pyftmerge:

$ pyftmerge Latn.ttf Geok.ttf

This command will merge the Latn.ttf font with the Geok.ttf font and write the result to a new font file called merged.ttf, containing the union of the glyphs present in the former two fonts. (BTW: Latn and Geok are ISO 15924 tags for Latin and Khutsuri scripts respectively.)

Not sure how pyftmerge behaves when a glyph is present in both fonts; I would assume the glyph from the font declared first will then take precedence. Also not sure how glyphs which map (through OpenType features and codepoint-to-glyphname mapping) to the same (Unicode) codepoint, but which have differing glyph names between both fonts are dealt with. I鈥檇 guess the implementation is naive and will merge _glyphs_, not _characters_, and thus that the glyph set of merged.[ttf|otf]will contain all glyphs with unique names.

pyftmerge doesn鈥檛 do any normalization anyway. Thus fonts that are of a different format (otf vs ttf) will not merge; fonts are expected to share the same vertical metrics, &c. I think this is why sometimes errors come up such as:

AssertionError: Expected all items to be equal: ['loca', NotImplemented]

and

KeyError: 'indexToLocFormat' 

I have not thoroughly tested all use cases yet, so I can鈥檛 tell whether it is possible to merge more than two font files at once, or if all OpenType features are preserved, let alone whether any attempt is made to also reconcile and merge conflicting OT feature statements, etc.

Merging two or more arbitrary font files surely is no sinecure! So, thanks a lot to all contributors of fonttools, for what it is already capable of doing!

All 3 comments

yeah, it's got no --help, only a very limited usage string when no arguments are provided.

usage: pyftmerge font...

Only two command line options are currently supported, --verbose and --timing (they work similar to pyftsubset).

Ideally we need to unify the current command line options parsing in the various scripts, perhaps using the argparse module.

argparse is nice.

For those wondering, this is how to use pyftmerge:

$ pyftmerge Latn.ttf Geok.ttf

This command will merge the Latn.ttf font with the Geok.ttf font and write the result to a new font file called merged.ttf, containing the union of the glyphs present in the former two fonts. (BTW: Latn and Geok are ISO 15924 tags for Latin and Khutsuri scripts respectively.)

Not sure how pyftmerge behaves when a glyph is present in both fonts; I would assume the glyph from the font declared first will then take precedence. Also not sure how glyphs which map (through OpenType features and codepoint-to-glyphname mapping) to the same (Unicode) codepoint, but which have differing glyph names between both fonts are dealt with. I鈥檇 guess the implementation is naive and will merge _glyphs_, not _characters_, and thus that the glyph set of merged.[ttf|otf]will contain all glyphs with unique names.

pyftmerge doesn鈥檛 do any normalization anyway. Thus fonts that are of a different format (otf vs ttf) will not merge; fonts are expected to share the same vertical metrics, &c. I think this is why sometimes errors come up such as:

AssertionError: Expected all items to be equal: ['loca', NotImplemented]

and

KeyError: 'indexToLocFormat' 

I have not thoroughly tested all use cases yet, so I can鈥檛 tell whether it is possible to merge more than two font files at once, or if all OpenType features are preserved, let alone whether any attempt is made to also reconcile and merge conflicting OT feature statements, etc.

Merging two or more arbitrary font files surely is no sinecure! So, thanks a lot to all contributors of fonttools, for what it is already capable of doing!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arrowtype picture arrowtype  路  8Comments

jenskutilek picture jenskutilek  路  7Comments

laerm0 picture laerm0  路  8Comments

black7375 picture black7375  路  4Comments

khaledhosny picture khaledhosny  路  11Comments