0

More specifically,

Using FontTools, how do I merge an OpenType font with a TrueType font (or a TrueType font with a TrueType font, if there is any difference in the command),

"Losslessly" or without resizing or messing with any glyphs (assume file size doesn't matter, the output font is for personal use),

And without replacing any glyphs in the TrueType font (merely adding additional unicode glyphs from the OpenType font).

The output font can be TrueType or OpenType, no preference as long as the above is requirements are satisfied. If possible, please explain if there are any differences.

Furthermore, the title/name of the output font should be the same as the title/name of the TrueType font.

Update: I consider this question mostly answered. The behavior of merge and pyftmerge seems to be more nuanced than described in the documentation. Generally, multiple glyphs of the same Unicode value will be overwritten. All UnicodeFull fonts, as long as they have the same Em Size, should merge regardless of whether they are OpenType or TrueType, while inclusion of a UnicodeBmp font will fail the merge regardless of whether the font is OpenType or TrueType.

There are no options or parameters for pyftmerge and the command is simply always:

pyftmerge [Primary font input] [Additional font input]

Existing glyphs for Unicode values in the primary font will not be overwritten and will take priority over the glyphs of any additional fonts. The name value/s of the output font will be the same as the primary font.

1 Answer 1

0

What you are asking needs some preliminary work.

From fonttools Merge multiple fonts into one (the text is bold in the source):

All fonts must currently have TrueType outlines (glyf table).

The fonttools project says in addition:

The project includes the TTX tool, that can convert TrueType and OpenType fonts to and from an XML text format, which is also called TTX. It supports TrueType, OpenType, AFM and to an extent Type 1 and some Mac-specific formats.

You will need to use the TTX tool to convert the OpenType font to TTX format, in order to be able to convert the TTX format to a TrueType font.

Once the two fonts are in TrueType format, then fonttools might be able to merge them.

2
  • Thanks for the answer and also for linking the documentation page. I carefully read through the page (and searched unfamiliar terms) and I believe it's not necessarily the case that an OpenType font won't have a glyf table. It also appears that merge has no options/parameters and handles duplicate glyphs for the same Unicode value in a very specific way. This probably means I'll have to discard the requirement of no duplicate glyphs and also attempt to merge fonts on a case by case basis. On the other hand, I may also be able to use a more general solution like the one you suggested.
    – Gnosis
    Jun 17, 2021 at 22:07
  • The situation with merge is not ideal for my purpose since I need to merge a large number of fonts. And unfortunately I'm not aware of any better solutions aside from FontTools. The alternative would likely be to manually merge fonts with FontForge, which will be extremely tedious.
    – Gnosis
    Jun 17, 2021 at 22:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .