1 /* Copyright 2013 Google Inc. All Rights Reserved.
3 Distributed under MIT license.
4 See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
7 /* A very simple commandline tool for decompressing woff2 format files to true
13 #include <woff2/decode.h>
16 int main(int argc
, char **argv
) {
18 fprintf(stderr
, "One argument, the input filename, must be provided.\n");
22 std::string
filename(argv
[1]);
23 std::string outfilename
= filename
.substr(0, filename
.find_last_of(".")) + ".ttf";
25 // Note: update woff2_dec_fuzzer_new_entry.cc if this pattern changes.
26 std::string input
= woff2::GetFileContent(filename
);
27 const uint8_t* raw_input
= reinterpret_cast<const uint8_t*>(input
.data());
29 std::min(woff2::ComputeWOFF2FinalSize(raw_input
, input
.size()),
30 woff2::kDefaultMaxSize
),
32 woff2::WOFF2StringOut
out(&output
);
34 const bool ok
= woff2::ConvertWOFF2ToTTF(raw_input
, input
.size(), &out
);
37 woff2::SetFileContents(outfilename
, output
.begin(),
38 output
.begin() + out
.Size());