Hi Behdad,
I did a quick try of TTX to .woff compiling.
Seems that there is no way to merge .xml metadata to resulting .woff file:
_ttx --flavor woff MyFontfile.ttx metadata.xml_
Is there a trick to add Metadata table into .ttx file first, or you believe that metadata is not necessary (like in extracompressed .woff2 format)?
Greetings from Anton (Berlin)
Hi Anton,
ttx does not support merging WOFF metadata from an xml file; neither does it support dumping WOFF metadata as XML format, if present in a compiled WOFF or WOFF2 font.
The TTX format currently does not expose any of the WOFF-specific attributes, and it simply represents the content of the uncompressed OTF/TTF.
On the other hand, the SFNTWriter and SFNTReader in fontTools/sfnt.py (as well as the WOFF2Reader and WOFF2Writer in fontTools/woff2.py) do support reading and writing metadata in WOFF and WOFF2 fonts.
So in theory you could write a python script to add your "metadata.xml" directly to a binary WOFF or WOFF2 font -- but not to a TTX file, as I explained above.
I hope that helps.
@antonxheight please have a look at #631. I added two scripts to the Snippets folder, to show how one can use fontTools to dump or merge WOFF metadata.
The first simply extracts the metadata to XML file in the same folder as the input font:
$ python Snippets/dump_woff_metadata.py /path/to/input_font.woff
The other script takes a metadata XML and a WOFF font, merging one into the other, and saves the result as a new WOFF file:
$ python Snippets/merge_woff_metadata.py /path/to/metadata.xml /path/to/input_font.woff
Wow, thank you very much Cosimo!
Anton
Most helpful comment
Hi Anton,
ttx does not support merging WOFF metadata from an xml file; neither does it support dumping WOFF metadata as XML format, if present in a compiled WOFF or WOFF2 font.
The TTX format currently does not expose any of the WOFF-specific attributes, and it simply represents the content of the uncompressed OTF/TTF.
On the other hand, the
SFNTWriterandSFNTReaderinfontTools/sfnt.py(as well as theWOFF2ReaderandWOFF2WriterinfontTools/woff2.py) do support reading and writing metadata in WOFF and WOFF2 fonts.So in theory you could write a python script to add your "metadata.xml" directly to a binary WOFF or WOFF2 font -- but not to a TTX file, as I explained above.
I hope that helps.