2 Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
20 #include "smpte_subtitle_asset.h"
35 cerr << "Syntax: " << n << " [OPTION] <MXF>\n"
36 << " -h, --help show this help\n"
37 << " -n, --no-fonts don't extract fonts\n";
41 main (int argc, char* argv[])
43 bool extract_fonts = true;
47 static struct option long_options[] = {
48 { "help", no_argument, 0, 'h'},
49 { "no-fonts", no_argument, 0, 'n'},
53 int c = getopt_long (argc, argv, "hn", long_options, &option_index);
64 extract_fonts = false;
69 if (argc <= optind || argc > (optind + 2)) {
74 dcp::SMPTESubtitleAsset sub (argv[optind]);
76 cout << sub.xml_as_string() << "\n";
79 map<string, dcp::Data> fonts = sub.fonts_with_load_ids ();
80 for (map<string, dcp::Data>::const_iterator i = fonts.begin(); i != fonts.end(); ++i) {
81 FILE* f = dcp::fopen_boost (i->first + ".ttf", "wb");
83 cerr << "Could not open font file " << i->first << ".ttf for writing";
86 fwrite (i->second.data().get(), 1, i->second.size(), f);