webfontsgoogle-fontswoffwoff2

Merging different .woff2 files into one


I downloaded a font via google fonts. That file comes in different styles(?), e.g.: black, italic, bold, etc. and each is a separate .ttf file:

Merriweather-BoldItalic.tff
Merriweather-LightItalic.tff
...

In order to use it as a webfont, i converted the files individually into .woff2 files using the woff2_compress command line tool. That also works and I got:

Merriweather-BoldItalic.woff2
Merriweather-LightItalic.woff2
...

Now I wonder: is it possible to merge all these .woff2 files into one, maintaining the style info for each file? If yes: which command line tool can I use?


Solution

  • You could use variable fonts.
    They include different design axis which could be interpolated to get e.g. different font-weights or font-widths.

    More and more google webfonts are also available as variable fonts.
    In your case the sans serif sibling "Merriweather Sans" is already available. The serif version can currently only be used as a traditional font.

    There's also a filter option on google fonts to show only variable fonts.

    google fonts options: show only variable fonts

    Traditional "static" fonts can't be merged into one file since they can't contain multiple font-styles.
    Technically, you could create a variable font yourself, but that's a pretty advanced task.

    There is also the TrueType Collection (TTC) format. But afaik: it's not supported by most browsers.

    BTW. if you need local woff2 copies of your fonts you can also use google webfont helper. This way you get the official woff2 versions - which might be more reliable than than self compiled font files.